Hi,
I have a gridview whitch is bind to sqlite source, before I filter the values by date the paging works fine.
when I filter the values I get result with 4 pages when I try the second page it goes back to all the values before the filtering.
I have seen some questions about the same problem on the web but no answer helped me.
this is how I load the values to the dataviewgrid:
C#
protected void Grid2()
{
string query2 = "Select * From SiteReport ORDER BY Date ASC";
databaseObject.OpenConnection();
SQLiteDataAdapter da2 = new SQLiteDataAdapter(query2, databaseObject.MyConnection);
da2.Fill(ds2);
GridView2.DataSource = ds2;
GridView2.DataBind();
databaseObject.CloseConnection();
}and this is how I filter by dates:
C#
protected void Button1_Click(object sender, EventArgs e)
{
ViewState.Add("flag", true);
string query3 = "SELECT * FROM SiteReport WHERE Date = '" + DatePicker2.CalendarDate.ToString("yyyy-MM-dd 22:45:00") + "'";
SQLiteCommand myCommand3 = new SQLiteCommand(query3, databaseObject.MyConnection);
databaseObject.OpenConnection();
SQLiteDataAdapter dx = new SQLiteDataAdapter(query3, databaseObject.MyConnection);
dx.Fill(ds3);
GridView2.DataSource = ds3;
GridView2.DataBind();
databaseObject.CloseConnection();
}this is how I tried the paging so far, but know I get blank gridview when I choose page 2:
C#
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
if (ViewState["flag"] != null)
{
if ((bool)ViewState["flag"] == true)
{
GridView2.PageIndex = e.NewPageIndex;
GridView2.DataSource = ds3;
GridView2.DataBind();
}
}
else
{
GridView2.PageIndex = e.NewPageIndex;
GridView2.DataSource = ds2;
GridView2.DataBind();
}
}Thanks,
Shay.

Ranganath PrasadRank #2,004 · 725 reputationPosted Jan 16, 2022, 3:18 PM EST
Vikas PanwarRank #1,447 · 1.1K reputationPosted Jan 16, 2022, 11:54 PM EST
shay a77 reputationPosted Jan 17, 2022, 4:22 AM EST
Amit MohantyRank #112 · 20K reputationPosted Jan 18, 2022, 3:41 AM EST