C# 数据列表中的按钮单击事件

C# 数据列表中的按钮单击事件,c#,javascript,asp.net,vb.net,C#,Javascript,Asp.net,Vb.net,我想通过DataList中的button click事件更改按钮的状态。请在这方面帮助我 <asp:DataList ID="DataList1" CaptionAlign="Right" runat="server" Width="100%" Visible="true"> <ItemTemplate> <table style="border-bottom:0px; border-left:0px; border-right:

我想通过DataList中的button click事件更改按钮的状态。请在这方面帮助我

<asp:DataList ID="DataList1" CaptionAlign="Right" runat="server" Width="100%" Visible="true">
      <ItemTemplate>
            <table style="border-bottom:0px; border-left:0px; border-right:0px;" width="100%"  border="0" cellspacing="0" cellpadding="0">                                                                            
              <tr>
                  <td width="120px"><asp:Label ID="lbl_ccode" runat="server" Text='<%#Bind("Fld_Couponcode")%>' ></asp:Label></td>
                  <td width="140px"><asp:Label ID="lbl_cval" runat="server" Text='<%#Bind("Fld_CouponValue")%>' ></asp:Label></td>
                  <td width="140px"><asp:Label ID="bl_status" runat="server" Text='<%#Bind("fld_status")%>' ></asp:Label></td>
                  <td width="140px"><asp:Button ID="btnstatus" runat="server" Text='<%#Bind("fld_status")%>' /></td>
             </tr>                                                                                                 </table>
      </ItemTemplate>
      <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
      <HeaderStyle BackColor="#507CD1" Font-Bold="True" HorizontalAlign="Left" ForeColor="White" />
</asp:DataList>

手柄

在DataGrid控件中单击任何按钮时发生

<asp:Button ID="btnstatus" CommandName="ChangeStatus" 
runat="server" Text='<%#Bind("fld_status")%>' />

  void ItemsGrid_Command(Object sender, DataGridCommandEventArgs e)
  {

     switch(((Button)e.CommandSource).CommandName)
     {

        case "ChangeStatus":

         // Add your code here

           break;

        default:
           // Do nothing.
           break;

     }

  }

void ItemsGrid_命令(对象发送方,DataGridCommandEventArgs e)
{
开关(((按钮)e.CommandSource.CommandName)
{
案例“变更状态”:
//在这里添加您的代码
打破
违约:
//什么也不做。
打破
}
}
CommandName=“ChangeStatus”在单击按钮时不起作用。请提供帮助。私有子项grid_命令(ByVal sender As[Object],ByVal e As DataGridCommandEventArgs)选择Case DirectCast(e.CommandSource,Button)。CommandName Case“Assigned”Dim status1 As Button=CType(e.Item.FindControl(“btnstatus”),Button)status1.Text=“赎回”退出“选择案例”或“不执行任何操作”。退出选择结束选择结束子项