C# 如何使用GridView事件

C# 如何使用GridView事件,c#,events,C#,Events,我有.aspx页面。在另一个gridviewParent中包含GridviewChild的。我的GridviewChild有带有一些控件的列,其中有下拉控件。我想在下拉列表中填写数据 GridViewParent GridViewChild Columns DropDownControl 这就是我想解释的层次结构。我可以在哪个网格的哪个事件上进行填充下拉?另外,如何获取所选值的事件有

我有.aspx页面。在另一个gridviewParent中包含GridviewChild的。我的GridviewChild有带有一些控件的列,其中有下拉控件。我想在下拉列表中填写数据

GridViewParent
           GridViewChild
                     Columns
                        DropDownControl

这就是我想解释的层次结构。我可以在哪个网格的哪个事件上进行填充下拉?另外,如何获取所选值的事件有哪些?如果可能,使用C向我发送代码可以使用GridViewChild控件的RowDataBound事件填充下拉列表。 要获得下拉列表的选定值,您可以这样说:

DropDownList ddl = GridViewParent.GridViewChild.Rows[someRowIndex].Cells[someCellIndex].FindControl("DropDownlist1") as DropDownList;
string v = ddl.SelectedItem.Text;

我希望这对u有益。

将子gridview与父数据绑定:

<ItemTemplate>
   <GridView id="childGrid" .. DataSource='<%# Eval("Items") %>' ItemDataBound="child_itemdatabound">
<ItemTemplate>

您也可以按照另一篇文章中提到的相同方式获取所选值。

我礼貌地建议您对您的问题再标记一些答案为已接受。好的,我会的,但这些答案必须让我满意,对吗?如果我对那些不满意的人这样做,这将是错误的。我问了很多问题,但没有得到答案。所以我怎么做亲爱的,。。。那么请帮帮我。。。
.. child_itemdatabound(..)
{
   DropDownList ddl = e.Row.FindControl("ddl") as DropDownList;
   if (ddl != null)
   {
      //Load from data source
      ddl.DataSource = dal.GetData();
      ddl.DataBind();

      //You can set the selected value here too; e.Row.DataItem represents the bound data object
   }
}