J
JohnE
Hello. I have a gridview that needs to have a nested gridview. I got it to
work using arrows but need to reclaim some real estate so I am moving over to
a row click to show the nested gridview. Will show the code at the end of
this post. What is occurring is the mouseover/onmouseout work. It is the
click of the row that causes the issue. I get a javascript error saying
'object required'. At the start of each row there is an 'Edit' that now also
throws the error but does go into the edit mode when the 'No' is clicked on
the error.
The error comes to this line in the javascript;
if (div.style.display == "none")
Here is the whole javascript plus the ondatabound code behind.
<script language="javascript" type = "text/javascript">
var currentlyOpenedDiv = "";
function CollapseExpand(object)
{
var div = document.getElementById(object);
if (currentlyOpenedDiv != "" && currentlyOpenedDiv != div)
{
currentlyOpenedDiv.style.display = "none";
}
if (div.style.display == "none")
{
div.style.display = "inline";
currentlyOpenedDiv = div;
}
else
{
div.style.display = "none";
}
}
</script>
protected void gvwChangeRequestList_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover",
"this.style.backgoundcolor='#4A4A4A'; this.style.cursor='pointer';
this.style.color='blue'");
e.Row.Attributes.Add("onmouseout",
"this.style.backgroundcolor='#FFFFFF'; this.style.color='black'");
e.Row.ToolTip = "Click on the row to view any children to " +
e.Row.Cells[2].Text;
GridView child = (GridView)e.Row.FindControl("gvwChild");
if (child != null)
{
SqlDataSource dbChild = new SqlDataSource();
dbChild.ConnectionString =
ConfigurationManager.ConnectionStrings["ProteusConnectionString"].ConnectionString;
dbChild.SelectCommand = "SELECT * " +
"FROM tblChangeRequest " +
"WHERE IsChildOf = '" +
((DataRowView)e.Row.DataItem)["ChangeRequestID"].ToString() + "' " +
"ORDER BY DevTargetEndDate";
child.DataSource = dbChild;
child.DataBind();
}
e.Row.Attributes.Add("onclick", "javascript:CollapseExpand('" +
e.Row.Cells[3].Text + "')");
}
}
I found the basic row click info when googling. Can anyone see what is
wrong here as to why the error and how to keep the 'Edit' from being involved
in the row click?
Thanks for your time.
.... John
work using arrows but need to reclaim some real estate so I am moving over to
a row click to show the nested gridview. Will show the code at the end of
this post. What is occurring is the mouseover/onmouseout work. It is the
click of the row that causes the issue. I get a javascript error saying
'object required'. At the start of each row there is an 'Edit' that now also
throws the error but does go into the edit mode when the 'No' is clicked on
the error.
The error comes to this line in the javascript;
if (div.style.display == "none")
Here is the whole javascript plus the ondatabound code behind.
<script language="javascript" type = "text/javascript">
var currentlyOpenedDiv = "";
function CollapseExpand(object)
{
var div = document.getElementById(object);
if (currentlyOpenedDiv != "" && currentlyOpenedDiv != div)
{
currentlyOpenedDiv.style.display = "none";
}
if (div.style.display == "none")
{
div.style.display = "inline";
currentlyOpenedDiv = div;
}
else
{
div.style.display = "none";
}
}
</script>
protected void gvwChangeRequestList_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover",
"this.style.backgoundcolor='#4A4A4A'; this.style.cursor='pointer';
this.style.color='blue'");
e.Row.Attributes.Add("onmouseout",
"this.style.backgroundcolor='#FFFFFF'; this.style.color='black'");
e.Row.ToolTip = "Click on the row to view any children to " +
e.Row.Cells[2].Text;
GridView child = (GridView)e.Row.FindControl("gvwChild");
if (child != null)
{
SqlDataSource dbChild = new SqlDataSource();
dbChild.ConnectionString =
ConfigurationManager.ConnectionStrings["ProteusConnectionString"].ConnectionString;
dbChild.SelectCommand = "SELECT * " +
"FROM tblChangeRequest " +
"WHERE IsChildOf = '" +
((DataRowView)e.Row.DataItem)["ChangeRequestID"].ToString() + "' " +
"ORDER BY DevTargetEndDate";
child.DataSource = dbChild;
child.DataBind();
}
e.Row.Attributes.Add("onclick", "javascript:CollapseExpand('" +
e.Row.Cells[3].Text + "')");
}
}
I found the basic row click info when googling. Can anyone see what is
wrong here as to why the error and how to keep the 'Edit' from being involved
in the row click?
Thanks for your time.
.... John