GridView 嵌套单选按钮<asp:TemplateField HeaderText="状态">
<ItemStyle Width="100px" />
<ItemTemplate>
<asp:RadioButton ID="rbt_y" runat="server" Text="显示" GroupName="b" />
<asp:RadioButton ID="rbt_n" runat="server" Text="隐藏" GroupName="b" />
</ItemTemplate>
</asp:TemplateField>如何根据表字段设置单选按钮的状态
<ItemStyle Width="100px" />
<ItemTemplate>
<asp:RadioButton ID="rbt_y" runat="server" Text="显示" GroupName="b" />
<asp:RadioButton ID="rbt_n" runat="server" Text="隐藏" GroupName="b" />
</ItemTemplate>
</asp:TemplateField>如何根据表字段设置单选按钮的状态
是访问GRIDVIEW 里面的控件吗?
是这个意思吗?
读取这一字段后,根据值来设置GridView模板列的两个单选按钮的状态.
<asp:RadioButton ID="rbt_n" runat="server" Text="隐藏" GroupName="b" Checked='<%# Convert.ToBoolean("datafield")%>' />
<ItemStyle Width="100px" />
<ItemTemplate>
<input id="isShow" type="text" runat="sever" style="display:none" value='<%# DataBinder.Eval(Container.DataItem, "你的列")%>'>
<asp:RadioButton ID="rbt_y" runat="server" Text="显示" GroupName="b" />
<asp:RadioButton ID="rbt_n" runat="server" Text="隐藏" GroupName="b" />
</ItemTemplate>
</asp:TemplateField> 数据绑定事件string strShow = ((TextBox)e.Row.FindControl("isShow")).value;
if(strShow == "1")
rbt_y.checked = checked;
................