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
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:
protected void g_GridCtrl_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
g_GridCtrl.PageIndex = e.NewPageIndex;
g_GridCtrl.DataBind();
}
void FillInGridView()
{
string myConnString = ConfigurationSettings.AppSettings["DSN_Fyrr"];
MySqlConnection myConnection = new MySqlConnection(myConnString);
string strSQL = "SELECT LocationName FROM PartLocationDef ORDER BY LocationName;" ;
MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(strSQL, myConnection);
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, "FailTypeDef");
g_GridCtrl.DataSource = myDataSet;
g_GridCtrl.DataBind();
myConnection.Close();
}
<asp:GridView ID="g_GridCtrl" runat="server" AllowSorting="true" AllowPaging="true" DataKeyNames="LocationName" OnPageIndexChanging="g_GridCtrl_PageIndexChanging" AutoGenerateColumns="False" OnSorting="g_GridCtrl_Sorting">
<Columns>
<asp:BoundField ReadOnly="true" HeaderText="Location Name" DataField="LocationName" SortExpression="LocationName" />
</Columns>
</asp:GridView>
Comment