I have a grid where the contents are from a parameter driven SQLDataSource and so I am rebinding in InitializeDataSource, PageIndexChanged and SortColumn. I have a cell button which takes an application specific action.
e.Cell.Row.DataKey in the ClickCellButton handler returns the wrong value. It looks like because no rebinding is done when ClickCellButton is triggered the grid dataset is incorrect. I have found that if I page the grid before I click the cell button (thus causing a rebind) then e.Cell.Row.DataKey returns the right value. I have tried doing a rebind in Page_Load if I detect that the grid was the cause of the postback. e.Cell.Row.DataKey then returns the right value but I now sometimes get Invalid postback or callback argument." . I have read that this can be caused by unnecessary postbacks.
ViewState is enabled. What should I be doing so that I get the right value from e.Cell.Row.DataKey?
Hi,
InitializeDataSource event is mainly used when you use XmlLOadOnDemand. When you navigate to a new page the grid will retrieve the values automatically and when you click on the button to do a postback e.Cell.Row.DataKey should be valid. Please refer to our samples we have a sample that implements paging for the WebGrid.
http://samples.infragistics.com/2009.2/WebFeatureBrowser/Default.aspx->WebGrid->Paging.
Magued