Wednesday, March 31, 2010

Coding for show child gridview in gridview row

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
Button b1 = (Button)row.FindControl("Button1");
GridView g1 = (GridView)row.FindControl("GridView2");
if (b1.Text == "Show")
{
g1.Visible = true;
b1.Text = "hide";
}
else if (b1.Text == "hide")
{
g1.Visible = false;
b1.Text = "show";
}
}

No comments: