Hi. I have a parent grid and a child grid below. If I click a row in the parent, the child grid will refresh with data associated to the row. I do this by getting the parent to call a "refresh" method in the child from the parent's "selectedIndexChanged" event. The "refresh" method gets data from the database. Then it calls a "rebind" on the grid, which calls the needDatasource method, then the ItemDataBound method. In the ItemDataBound, based on rules, I decide to show or hide an edit icon. When I select rows in the parent, this code fires, and tracing thru, it's setting the correct "true" value to the visible property of my edit icon, however when the page is shown, the icon is not there. Any reason why this is getting lost?
My ugly workaround is to add another method after the "rebind" that basically is the same as the ItemDataBound code which finds the grid, finds my rows, and shows/hides the icons.
public void RefreshChild)
6 Answers, 1 is accepted
If you could share a little more about the scenario or the methods you have mentioned, I'd be able to see and understand where the problem comes from and advise you accordingly. If would be helpful even if you could share the markup and code behind.
I look forward to hearing from you.
Thank you for the additional information.
Sometimes, it is would could be really helpful to share additional details on the scenario such as how the grid is created (declaratively, programmatically), which hierarchical structure is used? Is it Master/Detail tables or using Template hierarchy with NestedViewTemplate? These are details that are crucial and each can behave differently.
Based on the code snippets you have provided now, I assume that Child_Grid is in a NestedViewTemplate, is that correct? Can you tell me more about the deleteButton and editButton, are those UniqueNames of different columns? Are you using the built-in Edit/Delete columns or you're creating them using GridTemplateColumn?
Accessing controls in a Template column is different then in built-in columns. For more information, check out the Accessing Cells and Rows article.
I have attached a basic sample with no hierarchy but the grid has Template columns for Edit/Delete and some of the buttons are getting hidden based on condition of each row. I would like you to modify this sample to reflect the scenario from you side and send it back to us for further investigation.
Two separate radgrids.
When selectedIndexChanged occurs on the First, I call a refresh method on the second Radgrid.
The edit button is a GridEditCommandColumn, delete is a GridButtonColumn.
Accessing them isn't an issue. We do this logic in other areas of our app. Just seems for this, the changes in ItemDataBound do not stay so I have to call another method to do the same logic.
Have you had the chance to check out the sample project I have attached in my previous post? Can you confirm whether it works for you?
It would be very helpful If you could modify that sample project to produce the error and send it back to us for further investigation.