Hi
I am using above code on button submit to populate grid view after choosing one filter letsuppose between two dates.
first time when I got the results in my query it displays the data in grid but if I choose some other criteria form search filter let suppose date range which dont have any data grid shows no data but after that if I choose the correct parameter means correct date range where some data is there but grid still shows no data found.
I have to refresh the page only then the data will show only first time when it got some result in my querey.
I have debug the code and check the query and when run it in database it gives me result but in grid it wont show.
I searched it and try to use the 'clear' the grid but still not working.
Any help will be really appreciated.
public void PopulateGrid()
{
string Query = "SELECT RequestStatus, Count(Sno) as NumberofRequest FROM Test where RequestActive = 'Y' " + strDateFromTo + " group by RequestStatus";
Label1.Text = Query;
SqlConnection sqlcon = new SqlConnection(getconn());
SqlDataAdapter oAdapter = new SqlDataAdapter(Query, sqlcon);
DataSet ds = new DataSet();
oAdapter.Fill(ds);
dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
gridView1.DataSource = dt;
gridView1Approver.DataBind();
gridView1Approver.FooterRow.Cells[0].Text = "Total";
gridView1Approver.FooterRow.Cells[1].Font.Bold = true;
int totalAmount = 0;
for (int k = 1; k < dt.Columns.Count; k++)
{
totalAmount = dt.AsEnumerable().Sum(row => row.Field<int>(dt.Columns[k].ToString()));
gridView1Approver.FooterRow.Cells[k].Text = totalAmount.ToString();
gridView1Approver.FooterRow.Cells[k].Font.Bold = true;
gridView1Approver.FooterRow.BackColor = System.Drawing.Color.Beige;
}
}
else
{
Vlable.Text = "No record found.";
gridView1Approver.Visible = false;
}
}
Thanks