This is the code to my webgrid:
<asp:UpdatePanel ID="_UP1" runat="server">
<ContentTemplate>
<igtbl:UltraWebGrid ID="UG1" runat="server" Browser="Xml" Height="200px" Width="325px"
DataSourceID="getCustomerHeader" DataKeyField="cus_no">
<Bands>
<igtbl:UltraGridBand>
<AddNewRow View="NotSet" Visible="NotSet">
</AddNewRow>
</igtbl:UltraGridBand>
</Bands>
<DisplayLayout BorderCollapseDefault="Separate" LoadOnDemand="Xml" AutoGenerateColumns="true"
AllowSortingDefault="Yes" HeaderClickActionDefault="SortSingle" Name="ctl06xUG1"
RowHeightDefault="20px" Version="4.00">
<ActivationObject BorderColor="" BorderWidth="">
</ActivationObject>
<FrameStyle Height="250px" Width="100%">
</FrameStyle>
</DisplayLayout>
</igtbl:UltraWebGrid>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="_prodCatButton" EventName="Click" />
</asp:UpdatePanel>
As you can see it is in an update panel. When I click my button to fill the grid, everything works great. But when I sort on a column the grid looks as if it is doing an asyncpostback, but the grid cells are empty when it finishes. I have the same number of rows, just the cells are empty. Anybody have any clue what I am doing wrong.
the grid is bound to a SQLDataSource that is actually running a stored procedure on the SQL Server.
Hello.
A good solution to this problem would be to use query strings and extract their values in the pages OnInit event. This way, you can look at what the user selected on the client and pass those parameters into the SqlDataSource. You don't want to re-bind the grid again in the button click event.
Once the grid is bound at design time to the SqlDataSource, it will invoke the SqlDataSource_Selecting event. This is where the SqlDataSource invokes the select command. When the page is first requested, Page_Load will fire before SqlDataSource_Selecting. On every subsequent postback, however, SqlDataSource_Selecting will fire prior to Page_Load, and prior to any button click event. It will also fire before the grids SortColumn event. In all cases, OnInit fires before SqlDataSource_Selecting.
Since you are using XmlLoadOnDemand, the sorting is always done on the server regardless of the settings. When you click a column header and try to sort, the SqlDataSource_Selecting event fires before the grid will sort. It has to be loaded with data in order to sort. Since you are not passing back anything in a query string or a hidden control, it selects nothing from your Sql data base and the rows are lost. You need to populate the grid prior to any of the other control events so that it has data and can be sorted, grouped, etc.
Using query strings or hidden controls will allow you to send the appropriate parameters back to the server so that you can extract them so they are available for use by the SqlDataSource when SqlDataSource_Selecting fires. This way, the grid will be correctly populated and sorting and grouping can take place.
Please let me know if you have any other questions.