Shanna
Shanna

Reputation: 783

paging of gridview

i have a gridview where i have allowed paging. but when i click second page the gridview disappears here is the c# code :

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        OdbcDataAdapter adpState = new OdbcDataAdapter("SELECT CALL_NO,TDATE,
        ID_NO,NAME,CONTACT,DEPARTMENT,ISSUE,STATUS FROM TBL_ITHELPDESK 
        WHERE (STATUS IS NULL OR STATUS <> 'CLOSED') AND  TDATE= TO_DATE('" +
          txtDate.Text.ToString().Trim() + "','MM-DD-YYYY')", con1);
        DataSet ds = new DataSet();
        adpState.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();    
    }

can anyone help to find where i'm going wrong

Upvotes: 4

Views: 125

Answers (1)

syed mohsin
syed mohsin

Reputation: 2938

You have to check multiple things.

  1. Check the query with the one that is working, Is it Same?
  2. Check the con1 variable is defined outside of any other method.

Define con1 in a class not in a method, something like that

 odbcConnection con = new odbcConnection(ConectionString);

Upvotes: 3

Related Questions