未为asp.net中的radiobuttinlist触发gridview的行命令事件

未为asp.net中的radiobuttinlist触发gridview的行命令事件,asp.net,aspxgridview,rowcommand,Asp.net,Aspxgridview,Rowcommand,我在gridview的ItemTemplet字段中设置了rdiobutton list,该字段设置为ispostback=true,但radiobutton list仍然没有为gridview触发row_命令事件。如果我对button执行相同的操作,则它可以正常工作。我已经在(!IspostBack)中编写了绑定网格的代码,但问题仍然是 好了,我怎样才能摆脱这些 这是我网格的代码 <asp:GridView ID="grdSalesPerson" runat="server" AutoGe

我在gridview的ItemTemplet字段中设置了rdiobutton list,该字段设置为ispostback=true,但radiobutton list仍然没有为gridview触发row_命令事件。如果我对button执行相同的操作,则它可以正常工作。我已经在(!IspostBack)中编写了绑定网格的代码,但问题仍然是 好了,我怎样才能摆脱这些

这是我网格的代码

<asp:GridView ID="grdSalesPerson" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" OnRowCommand="grdSalesPerson_RowCommand">
                    <Columns>
                        <asp:BoundField DataField="SalesPersonID" HeaderText="SalesPersonID" />
                        <asp:BoundField DataField="FirstName" HeaderText="First Name" />
                        <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                        <asp:BoundField DataField="UserName" HeaderText="User Name" />
                        <asp:BoundField DataField="StateName" HeaderText="State Name" />
                        <asp:BoundField DataField="CityName" HeaderText="City Name" />

                        <asp:TemplateField HeaderText="Is Active">
                            <ItemTemplate>
                                <asp:RadioButtonList ID="rbActive" runat="server" CommandName="IsAct" AutoPostBack="true">
                                    <asp:ListItem>Yes</asp:ListItem>
                                    <asp:ListItem>No</asp:ListItem>
                                </asp:RadioButtonList>
                            </ItemTemplate>
                        </asp:TemplateField>  
                    </Columns>
                </asp:GridView>

当您选中任何单选按钮时,在e.commandname中会得到什么。附加一个调试器并检查该值。我在grdSalesPerson_RowCommand事件的开始处设置了断点,但它根本没有触发事件。但它会触发回发事件。您是否手动创建了此事件。因为您的事件没有正确创建。使用智能标记并再次创建事件。我想你已经有重复的问题了,我还没有手动创建此事件。事实上,同样的事件也适用于button。
protected void grdSalesPerson_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
{
    if (e.CommandName == "IsAct")
    {
        //  GridViewRow row = (GridViewRow) (((Button)grdSalesPerson.FindControl("btnIsActive")).NamingContainer);
        GridViewRow row = (GridViewRow)(((RadioButton)e.CommandSource).NamingContainer);
        int i = Convert.ToInt32(row.Cells[0].Text);
    }
}