Nov 11, 2010, 3:13 AM
how to redirect to a current page after refreshing grid pannel?
Hi,
I have 40 record in database. But I am displaying 10 record in each page in store grid by using grid pannel.Similarlly, I am using Ajax for events. But the problem is when I refresh the page or grid, it shows first record in first page. how can I get current page data when refreshing data? How can I avoid this problem, anybody can help me...
code:
protected void Refresh_Click(object sender, StoreRefreshDataEventArgs e)
{
Refresh();
pgtCombo.PageIndex = Convert.ToInt32(Session["pgIndex"]);
pgtCombo.PageSize = Convert.ToInt32(Session["pgSize"]);
Session["pgIndex"] = string.Empty;
Session["pgSize"] = string.Empty;
}
protected void Refresh()
{
try
{
Session["pgIndex"] = Convert.ToInt32(pgtCombo.PageIndex.ToString());
Session["pgSize"] = Convert.ToInt32(pgtCombo.PageSize.ToString());
string name = Convert.ToString(cmbSearch.SelectedItem.Value);
SqlConnection con = new SqlConnection(@"Integrated Security=SSPI;Initial Catalog=SUBBU; Data Source=vsspldev-09\SQLEXPRESS");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = string.Format("SELECT * FROM EMPLOYEE");
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.ExecuteNonQuery();
DataSet ds = new DataSet();
SqlDataAdapter daa = new SqlDataAdapter(cmd);
daa.Fill(ds, "EMPLOYEE");
con.Close();
this.stoCombo.DataSource = ds;
this.stoCombo.DataBind();
}
catch
{
throw new Exception("Connection Error!");
}
}
I have 40 record in database. But I am displaying 10 record in each page in store grid by using grid pannel.Similarlly, I am using Ajax for events. But the problem is when I refresh the page or grid, it shows first record in first page. how can I get current page data when refreshing data? How can I avoid this problem, anybody can help me...
code:
protected void Refresh_Click(object sender, StoreRefreshDataEventArgs e)
{
Refresh();
pgtCombo.PageIndex = Convert.ToInt32(Session["pgIndex"]);
pgtCombo.PageSize = Convert.ToInt32(Session["pgSize"]);
Session["pgIndex"] = string.Empty;
Session["pgSize"] = string.Empty;
}
protected void Refresh()
{
try
{
Session["pgIndex"] = Convert.ToInt32(pgtCombo.PageIndex.ToString());
Session["pgSize"] = Convert.ToInt32(pgtCombo.PageSize.ToString());
string name = Convert.ToString(cmbSearch.SelectedItem.Value);
SqlConnection con = new SqlConnection(@"Integrated Security=SSPI;Initial Catalog=SUBBU; Data Source=vsspldev-09\SQLEXPRESS");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = string.Format("SELECT * FROM EMPLOYEE");
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.ExecuteNonQuery();
DataSet ds = new DataSet();
SqlDataAdapter daa = new SqlDataAdapter(cmd);
daa.Fill(ds, "EMPLOYEE");
con.Close();
this.stoCombo.DataSource = ds;
this.stoCombo.DataBind();
}
catch
{
throw new Exception("Connection Error!");
}
}