Hi,
I'm trying to add a nested gridview to a parent gridview.
The code working correctly but I have a problem when I reload the page using
protected void btreload_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
BindData();
}
Because the button in parent gridview of getting nested gridview don't longer open the nested gridview.
I need reopen the nested GridView open after reload page
This is my code gv_parent_RowDataBound
if (e.Row.DataItem != null)
{
GridView gv_Child = (GridView)e.Row.FindControl("gv_Child");
if (gv_Child != null)
{
string customerId = gvProducts.DataKeys[e.Row.RowIndex].Value.ToString();
DataSet ds = new DataSet();
using (MySqlConnection myConnectionString =
new MySqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString))
{
using (MySqlCommand cmd =
new MySqlCommand("SP_CHILD", myConnectionString))
{
cmd.Connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("tun", Request.QueryString["un"]);
cmd.Parameters.AddWithValue("tmo", Request.QueryString["mo"]);
cmd.Parameters.AddWithValue("tcustomerId", customerId);
MySqlDataAdapter adapter = new MySqlDataAdapter();
GridView gvOrders = (GridView)e.Row.FindControl("gvOrders");
adapter = new MySqlDataAdapter(cmd);
adapter.Fill(ds);
cmd.Connection.Close();
gv_Child.DataSource = ds.Tables[0];
gv_Child.DataBind();
}
}
}
}