0

我在网格中有一个编辑项模板,如下面的代码所示:

<telerik:GridTemplateColumn HeaderText="<%$Resources:Resources,Sex  %>" UniqueName="EmpSex" DataField="sex"> <ItemTemplate> <asp:Label ID="EmpSexLb" runat="server" Text='<%# Eval("sex") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <input type="radio" name="Sexe" id="Radio1" checked="<%# Eval("sex").ToString()=="M"? "checked":"" %>"/> male  <input type="radio" name="Sexe" id="Radio2" checked="<%# Eval("sex").ToString()=="F"? "checked":"" %>"/> female </EditItemTemplate></telerik:GridTemplateColumn>

如何在 radgrid 的 itemCommand 事件中从服务器端读取无线电输入?

提前致谢

4

1 回答 1

1

请尝试使用以下代码片段。

ASPX

<telerik:GridTemplateColumn>
                    <EditItemTemplate>
                        <input type="radio" name="Sexe" id="Radio1" checked="true" runat="server" />
                        male 
                        <input type="radio" name="Sexe" id="Radio2" runat="server" />
                        female
                    </EditItemTemplate>
 </telerik:GridTemplateColumn>

ASPX.CS

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.UpdateCommandName)
    {
        GridEditableItem item = e.Item as GridEditableItem;
        System.Web.UI.HtmlControls.HtmlInputRadioButton Radio1 = (item.FindControl("Radio1") as System.Web.UI.HtmlControls.HtmlInputRadioButton);
        System.Web.UI.HtmlControls.HtmlInputRadioButton Radio2 = (item.FindControl("Radio2") as System.Web.UI.HtmlControls.HtmlInputRadioButton);
        //Access your radio button here
    }
}

让我知道是否有任何问题。

于 2013-09-24T05:39:19.843 回答