【问题标题】:ChildGridView column's Data On Binding子 GridView 列数据绑定
【发布时间】:2011-09-02 10:31:39
【问题描述】:

我正在使用嵌套的 gridview,在 RowDatabound 事件上,我正在根据 parentgridview 列的某些条件绑定 childgridview。同时我需要知道子gridview的列值。我该怎么做? 我正在使用此代码:-

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 ????
      }
   }
}

【问题讨论】:

    标签: asp.net data-binding gridview datagridview


    【解决方案1】:

    有几种方法可以实现:

    1- 遍历 Child GridView 的行

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

    2- 使用子GridView的RowDataBound事件

    【讨论】:

      猜你喜欢
      • 2013-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-31
      相关资源
      最近更新 更多