|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to refresh a parent grid?Greetings all,
I have a nested datagrid setup. When one updates the child grid using edit, it also updates a field in the parent grid (the parent grid update is done using a simple select query inside the child grid's update sub). All is well, *however* after the update occurs the parent grid is still displaying the old data even though the update has occured. I was under the assumption that when I did a .databind() on the child grid, the parent grid automatically reloaded? Well, evidently it doesn't. :-/ In order to see the right data in the parent grid, I have to leave the page then come back. What do I do to get the parent grid to display the current data after updating the child grid? I've tried many differents ways of getting access to the parent grid from within the child grid's update sub, but all have met with failure. Help! Hi Roy,
Is it that you can't get a reference to the parent grid and therefore called call its DataBind method? Posting some code would help us work this out. Ken Show quoteHide quote "Roy" <roy.ander***@gmail.com> wrote in message news:1107901886.109816.325970@o13g2000cwo.googlegroups.com... > Greetings all, > > I have a nested datagrid setup. When one updates the child grid using > edit, it also updates a field in the parent grid (the parent grid > update is done using a simple select query inside the child grid's > update sub). All is well, *however* after the update occurs the parent > grid is still displaying the old data even though the update has > occured. I was under the assumption that when I did a .databind() on > the child grid, the parent grid automatically reloaded? Well, evidently > it doesn't. :-/ In order to see the right data in the parent grid, I > have to leave the page then come back. > > What do I do to get the parent grid to display the current data after > updating the child grid? I've tried many differents ways of getting > access to the parent grid from within the child grid's update sub, but > all have met with failure. Help! > Exactly.
The nested datagrid is in the form of a user control .ascx page and I cannot seem to reference the parent grid from within the user control. It pops up an error when I try to do a parentgrid.databind() or execute the parentgrid's bind_parentgrid() sub. I'm uncertain what I could post short of posting the entire app... What section, specifically, would you like to have a gander at? Roy,
I think you are having a problem similar to mine (see "parent/child" datagrids question posted today... Here's a snippet of code from what I'm doing, this is from the User Control. To access the parent grid (in my case called "myHGrid") you can create a new dataGrid and set it equal to the parent datagrid. I did this just to get the value of the selected index of the parent DataGrid. Sorry it's in C#, but you should get the idea.: DataGrid myDataGrid = new DataGrid(); myDataGrid = (DataGrid) this.Parent.FindControl("myHGrid"); int myIndex = 0; try { myIndex = Convert.ToInt32(myDataGrid.DataKeys[myDataGrid.SelectedIndex]); } catch{} ------------------------------------------------------------------------------- Now, for your first problem I think it's just a post back thing. When you edit your child datagrid, you're posting back to the parent page. So it will not rebind the data for your datagrid unless you tell it to. So in the page_load function, make sure you call your function (sub) to bind the parent datagrid even if the page is a post back. Also, If you don't mind would you check out the post I put up today....perhaps you already tackled that problem? Thanks, -Danny Show quoteHide quote "Roy" wrote: > Exactly. > > The nested datagrid is in the form of a user control .ascx page and I > cannot seem to reference the parent grid from within the user control. > It pops up an error when I try to do a parentgrid.databind() or execute > the parentgrid's bind_parentgrid() sub. > > I'm uncertain what I could post short of posting the entire app... What > section, specifically, would you like to have a gander at? > > |
|||||||||||||||||||||||