2011-09-02 55 views
0

我在RowDatabound上使用嵌套的gridview事件我綁定childgridview基於parentgridview列的某些條件。與此同時,我需要知道child gridview的列值。我可以這樣做嗎? 我使用這個代碼: - :通過兒童的GridView的行ChildGridView列的綁定數據

1-環

foreach (GridViewRow row in childGridView.Rows) 
{ 
    //row.Cells[index]; 
} 

2-使用RowDataBound事件

protected void gridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
     GridView gridViewchild = (GridView)e.Row.FindControl("gridView2"); 
     string custState = ((DataRowView)e.Row.DataItem)["CustState"].ToString(); 
     if (!string.IsNullOrEmpty(custState)) 
     { 
      gridViewchild .DataSource = MyDataSource; 
      gridViewchild .DataBind(); 
      //now i need to know the childgridview column's data ???? 
     } 
    } 
} 

回答

1

有幾個方法可以做到這一點的子GridView

+0

: - 非常感謝。 – Pranav