I am using a standart .net 2.0 Gridview which uses an XMLDatasource to populate the Grid. The Data property of the XMLDatasource is set dynamically which allows the gridview to change based on input.
All this works fine however I am having problems with paging...
I have set the AllowPaging Property to "true" and set the PageSize Property to "10". The GridView populates fine the first time around showing the first 10 records and the number of pages as hyperlinks at the bottom, BUT when i try to click on any of the page numbers to view them a message box pops up saying "Object reference not set to an instance of an object"
any ideas what I'm doing wrong?? or is there anything i need to do which i have missed out on??
Code currently being used;
Gridview...
<asp:GridView ID="GridView1"
Runat="server"
DataSourceID="XmlDataSource1"
AutoGenerateColumns="False"
AllowPaging="True"
style="width:100%; height:100%;"
EnableViewState="False">
<SelectedRowStyle BackColor="Red" />
<Columns>
<asp:BoundField DataField="TYPE" HeaderText="TYPE" SortExpression="TYPE" />
<asp:BoundField DataField="DESCRIPTION" HeaderText="DESCRIPTION" SortExpression="DESCRIPTION" />
</Columns>
</asp:GridView>
XMLDatasource...
<asp:XmlDataSource ID="XmlDataSource1" runat="server" TransformFile="~/XML/grid2.xslt" EnableCaching="False">
</asp:XmlDataSource>
vb.net code which sets the Data property of the XMLDatasource...
Private Sub btnTest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTest.Click
XmlDataSource1.Data = _testLib.GetGridXML(_Num)
GridView1.DataBind()
End Sub
where _testLib.GetGridXML is a function that returns an XML string based on the _Num passed in.