Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested datagrid problems

Status
Not open for further replies.

TeaAddictedGeek

Programmer
Apr 23, 1999
271
0
0
US
Is there a way I can access a nested datagrid without raising a DataGridItemEventArgs event? I'm trying to toggle its visibility with an ImageButton, but so far no luck.


Thanks!

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs."
-Joseph Weizenbaum
 
Not sure what you mean.. there is no DataGridItemEventArgs event of a datagrid. And what do you want to toggle the visbilbiy on, the grid, or nested grid?
 
Perhaps I'm not explaining myself clearly. I'm looking to toggle the visibility of the nested grid. I can toggle it from a grid event from a method such as this:

protected void dgChildGrid_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
...
}

or even here:

protected void dgParentGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
...
}

But I'd be looking to do it from an OnClick event from an ImageButton. The only way I know of to access a nested datagrid is through e.Item.FindControl("dgChildGrid") via one of the above examples.

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs."
-Joseph Weizenbaum
 
The problem is in order to make one of the child grids visible/invisibe is to bind ghe main grid and do your code as you have posted.. there is no other way.
 
Yeah, I've tried divs but for some reason the Javascript keeps getting overwritten by the ASP.NET code. Apparently this has worked before in ASP.NET 1.1 but it doesn't seem to be working in 2.0. :/ I'll keep trying. Thanks!

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs."
-Joseph Weizenbaum
 
You could surround the nested data grid in a <div> tag with a css style of display:block or display:none based on the click of your image button.

 
Believe me, I tried that, and the div keeps getting overwritten with each load to the page.

I'm desperately trying to find a solution to this in ASP.NET 2.0 and it doesn't look like there is one without going to AJAX, a technology I have yet to be familiar with.

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs."
-Joseph Weizenbaum
 
I'm going to play with this later. I have a GridView where I have rows I hide/display that don't have nested GridViews in them, but I dont see why putting one in with what I've done would effect my code. Then I'll follow up here for you, hopefully with a working code sample :)
 
I am not sure if I have this right but you could try setting the imagebuttons "commandname" to something sensible. Then in the outer datagrid raise the _ItemCommand

and do your find control in there
Code:
   Protected Sub myDataGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
        If e.CommandName = "doit" Then
            Dim dg As DataGrid = e.Item.FindControl("TheOtherGrid")
        End If
    End Sub
 
Nope, I got another solution in a different thread. Thanks!

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs."
-Joseph Weizenbaum
 
Can you post your other solution or the thread where it is explained? Thanks.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top