Last post Apr 17, 2014 04:42 AM by Happy Chen - MSFT
Apr 16, 2014 03:51 AM|bjay.tiamsic26|LINK
Hello. I have a nested gridview in my application.
How can I set the 2nd gridview shown by default. (without setting Style="display:none"
Apr 16, 2014 04:21 AM|Nizam Mohammed|LINK
Set ID to gridview and runat="Server"
Deal with code behing
Gridview.Visible = "True/False"
Apr 17, 2014 04:42 AM|Happy Chen - MSFT|LINK
According to your description, In the RowDataBound box, type
GridView1_RowDataBound and then press ENTER.
Visual Web Developer creates an event handler for the RowDataBound event of the
GridView control. The code will resemble the following code example.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
//add your codes according to your condition
string customerID = grdViewCustomers.DataKeys[e.Row.RowIndex].Value.ToString();
GridView grdViewOrdersOfCustomer = (GridView)e.Row.FindControl("grdViewOrdersOfCustomer");
grdViewOrdersOfCustomer.DataSource = SelectData(
"SELECT top 3 CustomerID, OrderID, OrderDate FROM Orders WHERE CustomerID='" +
customerID + "'");
please refer to the links below for details:
Walkthrough: Creating a Nested GridView Control
Hope it helps you.