Hi,
I'm using UWG 2008.2 (CLR 3.5) with the latest patch (.2.20082.2149).
The grid is set to LoadOnDemand="Xml" and the InitializeDataSource event is implemented.
Everything works fine and the grid loads additional date when scrolled down. The grid is inside an AJAX updatepanel. When the user selects a row and presses on a seperate edit button, I get the selected row from the grid and open a dialog in the buttons click event. This works just fine if the grid hasn't been scrolled down (hasn't been loading on demand). If the grid did load additional data the SelectedRows collection is always empty, eventhough a row was selected by the user.
I found out that the InitializeDataSource event is fired before the button click event. But the SelectedRows collection is already empty when InitializeDataSource is fired.
This is a huge problem for me and I urgently need a solution.
Thank you for your help.
As I still have this problem, and it also occurs when a filter is applied....I had to find a solution.
Here it is:
I'm using clientside events to store the ID of the selected row in a hidden field. In my case the ID is stored in the first cell of my data.
You need to put these two functions in your page:
<script language="javascript" type="text/javascript"> function uwgGroups_CellClickHandler(gridName, cellId, button) { var rowObj = igtbl_getRowById(cellId); if (rowObj != null) { if (rowObj.getDataKey() == null) { igtbl_cancelPostBack(rowObj.gridId) } else { var tf = document.getElementById('<%=txtSelID.ClientID%>'); tf.value = rowObj.getCell(0).getValue(); } } } function uwgGroups_RowSelectorClickHandler(gridName, rowId, button) { var rowObj = igtbl_getRowById(rowId); if (rowObj != null) { if (rowObj.getDataKey() == null) { igtbl_cancelPostBack(rowObj.gridId) } else { var tf = document.getElementById('<%=txtSelID.ClientID%>'); tf.value = rowObj.getCell(0).getValue(); } } } </script>
Then you have to add the following field to your markup:
<input id="txtSelID" type="hidden" value="" runat="server" />
Finally you need to bind the two functions to the grid:
<DisplayLayout>
<ClientSideEvents CellClickHandler="uwgGroups_CellClickHandler" RowSelectorClickHandler="uwgGroups_RowSelectorClickHandler"/>
</DisplayLayout>
In your codebehind you can now access the selected ID by: txtSelID.Value
Hope that's helpful for other people :)
WebDataGrid is a brand new control, built atop of our "Aikido" framework (and so built atop of Microsoft's ASP.NET AJAX framework). It has a different object model and different capabilities than WebGrid.
The following forum thread includes discussion involving our ASP.NET product manager, regarding comparison between th two controls, and the kinds of though processes we suggest when choosing which one to use:http://forums.infragistics.com/forums/t/16141.aspx
Thank you for your quick reply!
I have one question. I've never used the new WebDataGrid. Is it compatible with WebGrid? Can I just change the "assembly" and the name or does it have different properties and settings?
Meaning: Is there a simple and fast way to migrate an existing WebGrid application to WebDataGrid?
Thanx for your help!
sbitsolution said:The grid is set to LoadOnDemand="Xml" and the InitializeDataSource event is implemented.
sbitsolution said:The grid is inside an AJAX updatepanel.
WebGrid's AJAX functionality (LoadOnDemand="XML") uses a different AJAX implementation than used by the ASP.NET AJAX Extensions framework (used by UpdatePanel). The two AJAX implementations cannot work at the same time.
I recommend that you either replace UpdatePanel with WebAsyncRefreshPanel (which uses the same AJAX framework as WebGrid), replace WebGrid with WebDataGrid (which uses ASP.NET AJAX Extensions), or disable the AJAX functionality of WebGrid (and can continue using UpdatePanel).
sbitsolution said:I found out that the InitializeDataSource event is fired before the button click event. But the SelectedRows collection is already empty when InitializeDataSource is fired.
One option is to disable the grid's AJAX functionality. In this way, you can persist the grid's selected rows across postbacks. You still have the UpdatePanel for AJAX functionality. Depending on the reason you're using the grid's AJAX functionality, disabling it is likely the best option.
Another option is to persist information about what was selected in some other fashion, so that you can access it on the server. This is not a trivial undertaking, and exact details will depend greatly on your application's details.