Hello,
I have a MySql data table that I display in a GridView in ASP .NET. The table is too large to display without paging, so I have added and OnPageIndexChan ging event and corresponding handler to the GridView. But, in the GridView, when I click the next page index, the grid view disappear. See my code below.
Any help on this is very appreciated.
Best regards
Kurt Jakobsen
Code: ( text )
protected void g_GridCtrl_Page IndexChanging(o bject sender, GridViewPageEve ntArgs e)
{
g_GridCtrl.Page Index = e.NewPageIndex;
g_GridCtrl.Data Bind();
}
void FillInGridView( )
{
string myConnString = ConfigurationSe ttings.AppSetti ngs["DSN_Fyrr"];
MySqlConnection myConnection = new MySqlConnection (myConnString);
string strSQL = "SELECT LocationName FROM PartLocationDef ORDER BY LocationName;" ;
MySqlDataAdapte r myDataAdapter = new MySqlDataAdapte r(strSQL, myConnection);
DataSet myDataSet = new DataSet();
myDataAdapter.F ill(myDataSet, "FailTypeDe f");
g_GridCtrl.Data Source = myDataSet;
g_GridCtrl.Data Bind();
myConnection.Cl ose();
}
<asp:GridView ID="g_GridCtrl " runat="server" AllowSorting="t rue" AllowPaging="tr ue" DataKeyNames="L ocationName" OnPageIndexChan ging="g_GridCtr l_PageIndexChan ging" AutoGenerateCol umns="False" OnSorting="g_Gr idCtrl_Sorting" >
<Columns>
<asp:BoundFie ld ReadOnly="true" HeaderText="Loc ation Name" DataField="Loca tionName" SortExpression= "LocationNa me" />
</Columns>
</asp:GridView>
I have a MySql data table that I display in a GridView in ASP .NET. The table is too large to display without paging, so I have added and OnPageIndexChan ging event and corresponding handler to the GridView. But, in the GridView, when I click the next page index, the grid view disappear. See my code below.
Any help on this is very appreciated.
Best regards
Kurt Jakobsen
Code: ( text )
protected void g_GridCtrl_Page IndexChanging(o bject sender, GridViewPageEve ntArgs e)
{
g_GridCtrl.Page Index = e.NewPageIndex;
g_GridCtrl.Data Bind();
}
void FillInGridView( )
{
string myConnString = ConfigurationSe ttings.AppSetti ngs["DSN_Fyrr"];
MySqlConnection myConnection = new MySqlConnection (myConnString);
string strSQL = "SELECT LocationName FROM PartLocationDef ORDER BY LocationName;" ;
MySqlDataAdapte r myDataAdapter = new MySqlDataAdapte r(strSQL, myConnection);
DataSet myDataSet = new DataSet();
myDataAdapter.F ill(myDataSet, "FailTypeDe f");
g_GridCtrl.Data Source = myDataSet;
g_GridCtrl.Data Bind();
myConnection.Cl ose();
}
<asp:GridView ID="g_GridCtrl " runat="server" AllowSorting="t rue" AllowPaging="tr ue" DataKeyNames="L ocationName" OnPageIndexChan ging="g_GridCtr l_PageIndexChan ging" AutoGenerateCol umns="False" OnSorting="g_Gr idCtrl_Sorting" >
<Columns>
<asp:BoundFie ld ReadOnly="true" HeaderText="Loc ation Name" DataField="Loca tionName" SortExpression= "LocationNa me" />
</Columns>
</asp:GridView>
Comment