Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > getting error on row click

Reply
Thread Tools

getting error on row click

 
 
JohnE
Guest
Posts: n/a
 
      03-20-2010
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





 
Reply With Quote
 
 
 
 
JohnE
Guest
Posts: n/a
 
      03-21-2010
Hi. For what I have below, there is more to add. After a break, I came back
and dug into this more. The nested gridview is there and populated. As I
had it display when the gridview opens. I found the problem in asking for
'object' is coming from the following line;

e.Row.Attributes.Add("onclick", "javascript:CollapseExpand('" +
e.Row.Cells[0].Text + "')");

When this line is commented out no error. When ('" + e.Row.Cells[0].Text +
"') this part is removed, no error. This is the object part of the
javascript function. So this is what should be looked at. And also a way to
avoid the first column with 'Edit' in it for editing the row.

Thanks...John



"JohnE" wrote:

> 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
>
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
click click click Andy Morrison Computer Support 7 12-20-2007 06:50 AM
1 click compiler and 1 click error Greg C++ 2 10-20-2006 02:07 AM
how to highlight a row when on click and keep it highlighted until next click john woo Javascript 1 06-16-2005 01:30 PM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Highlight the row and click anywhere to select a row in a GridView Fernando Lopes ASP .Net 0 04-28-2005 12:24 PM



Advertisments