private void dl_ItemCreated(object sender, DataListItemEventArgs e)
{

    if((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType ==ListItemType.AlternatingItem))

   { Button btnconf=(Button) e.Item.FindControl("btn");
     btnconf.Click+=new EventHandler(btnconf_Click);

    }}

   private void btnconf_Click(object sender, EventArgs e)
     {
Button btnconf=(Button)sender;       //怎样取出对应的DropDownList的id
                                       
    }

解决方案 »

  1.   

    在itemcommand里面写代码
    DataGridItem  gdi;
    gdi=e.Item;
    //(DropDownList)gdi.FindControl("Role");
    DropDownList drp = (DropDownList)gdi.FindControl("Role");
      

  2.   

    用button的CommandArgument把 drop的id带过去。
    ((Button)sender).CommandArgument.ToString();
      

  3.   

    <td width="60">
    <asp:DropDownList ID="ddl" Runat="server" Width="60">
    <asp:ListItem Value="1">aa</asp:ListItem>
    <asp:ListItem Value="2">bb</asp:ListItem>
    <asp:ListItem Value="3">cc</asp:ListItem>
    </asp:DropDownList></td>
    <td width="20">
    <asp:Button ID="btn" Runat="server" Text="确定" CommandName="btn"></asp:Button></td>
      

  4.   

    觉得没必要非得用委托你直接指定 DataGrid里Button的CommandName  设为"aa"在ItemCommand()里
    {
        if((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType ==ListItemType.AlternatingItem))
        {
              if (e.CommandName == "aa")
                  {
                      ((DropDownList)e.Item.FindControl("下拉框id")).SelectItem.Text;之类
                        dosomething...
                   }
         }
    }
    就可以了
                      
      

  5.   

    如果你非得用委托,恐怕得自己写个委托,再从EventArgs派生一个类,指定构造函数时加个参数,再关联委托时把DropDownList的值传进去 ,觉得麻烦死了