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
This may be an order of event issue. Try filling your typed data set in the page init event. This page init should fire before anything else and your data should be available by the time you get to you InitializeDataSource event.
Thanks. I am using NA v8.1, VS2008 and IE7 - WinXP Pro.
As I commented before, when a Page link is pressed, the UltraWebGrid1_InitializeDataSource event handler is called and the following asignment is made within: UltraWebGrid1.DataSource = m_objMyDS . This time -somehow- the tables lost their rows. I can assure that no where in the page I am clearing them.
The project is a simple AJAX-enabled Application (a single page and a Typed DataSet), which in fact I created to play around with ASP .NET, since I am a newbie in web developing.
Hrm. I don't see anything wrong. You dont need to handle PageIndexChanged and you don't need to do e.Cancel in InitializeDataSource. Here is what i am doing in code. I just dropped on a WebGrid, set the Browser property to Xml and wrote the following lines of code:
Protected Sub UltraWebGrid1_InitializeDataSource(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs) Handles UltraWebGrid1.InitializeDataSource Dim ds As New DataSet() Dim dt As New DataTable() Dim dt2 As New DataTable() dt.Columns.Add("a") dt2.Columns.Add("aa") For x As Integer = 1 To 100 dt.Rows.Add(x) Next For y As Integer = 1 To 100 dt2.Rows.Add(y) Next ds.Tables.Add(dt) ds.Tables.Add(dt2) ds.Relations.Add(New DataRelation("dr1", dt.Columns(0), dt2.Columns(0))) Me.UltraWebGrid1.DataSource = ds.Tables(0) End Sub Protected Sub UltraWebGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles UltraWebGrid1.InitializeLayout e.Layout.Pager.AllowPaging = True e.Layout.Pager.PageSize = 20 e.Layout.LoadOnDemand = Infragistics.WebUI.UltraWebGrid.LoadOnDemand.Xml End Sub
I did this in 7.3.20073.38 using Visual Studio 2005 in IE7. See if you have any other settings set. What version of NA are you using? In what environment is this in?