Hello
I have a webgrid that uses LoadOnDemand(xml) and Paging (also xml). When a page link is pressed, the "loading" cursor is shown, but after a while the new page is not displayed - I still see page 1. The grid is bound at runtime to a hierarchical dataset (two tables). By the way, loading on demand the second band's rows do work.
What could be wrong?
Private m_objDS As New DS_MyTypedDataSetPrivate m_strConnectionString As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load m_strConnectionString = "Data Source=MyServer; Initial Catalog=MyDB;User ID=sa; Password=xyz;"
UltraWebGrid1.DisplayLayout.Pager.AllowPaging = True UltraWebGrid1.DisplayLayout.Pager.PageSize = 20
LoadDataSet()
UltraWebGrid1.DataSource = m_objDS UltraWebGrid1.DataBind()
End Sub
Thanks a lot.
It may have somethign to do with LoadOnDemand. Try setting your data in the InitializeDataSource event of the WebGrid instead of the Page_Load. If you are having trouble finding the event, you will not find it in the event list of the designer. You will either have to hook up the event through the xml markup or in the Page_Init. More information can be found here on Tony Lombardo's blog regarding WebGrid DataBinding (the "DataBinding in Code" section talks a little about the InitializeDataSource event:
http://blogs.infragistics.com/blogs/tony_lombardo/archive/2008/01/29/demystifying-infragistics-webgrid-databinding.aspx
Documentation on the Grid.DisplayLayout.LoadOnDemand property:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.1/CLR2.0/html/Infragistics2.WebUI.UltraWebGrid.v8.1~Infragistics.WebUI.UltraWebGrid.UltraGridLayout~LoadOnDemand.html
I added the following code but what happend is that when a page link is pressed, the grid shows no rows. Somehow, the datatables cleared the rows.
By the way, I don't understand why I have to continuosly asign the datasource property. In windows forms programming, once is just enough.
Any ideas? Thanks a lot.
Private Sub UltraWebGrid1_InitializeDataSource(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs) Handles UltraWebGrid1.InitializeDataSource UltraWebGrid1.DataSource = m_objMyDS e.Cancel = FalseEnd Sub
Private Sub UltraWebGrid1_PageIndexChanged(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.PageEventArgs) Handles UltraWebGrid1.PageIndexChanged UltraWebGrid1.DisplayLayout.Pager.CurrentPageIndex = e.NewPageIndex UltraWebGrid1.DataBind()End Sub