How to get OnPageIndexChanging in C# .NET to work with MySql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kurt Jakobsen
    New Member
    • Jun 2007
    • 38

    How to get OnPageIndexChanging in C# .NET to work with MySql

    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:
    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>
    Last edited by Atli; Jun 26 '07, 12:28 PM. Reason: Added code tags
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    This is more of a .Net problem than a MySQL problem so I'm moving it over to the .Net forums.

    Moderator

    Comment

    Working...