<asp:TemplateField HeaderText="单元状态">
<itemtemplate>
<asp:RadioButtonList ID="rbtnlist1" runat="server" RepeatDirection="Horizontal">
<asp:ListItem value="营业" text="营业" width="50px"/>
<asp:ListItem value="空置" text="空置" width="50px"/>
<asp:ListItem value="停用" text="停用" width="50px"/>
<asp:ListItem value="歇业" text="歇业" width="50px"/>
</asp:RadioButtonList>
</itemtemplate>
</asp:TemplateField>数据库中有一字段 DYZT,值只能为 营业,空置, 停用, 歇业 四者其中之一。但是现在数据库中只有营业,空置。
需求:从数据库中读取 DYZT 的值,根据值 让页面上的RadioButtonList中的对应按钮被选中。当用户修改选项之后 点击保存,将对应的修改 写入数据库.最好有具体的代码。谢谢.急!急!急!
<itemtemplate>
<asp:RadioButtonList ID="rbtnlist1" runat="server" RepeatDirection="Horizontal">
<asp:ListItem value="营业" text="营业" width="50px"/>
<asp:ListItem value="空置" text="空置" width="50px"/>
<asp:ListItem value="停用" text="停用" width="50px"/>
<asp:ListItem value="歇业" text="歇业" width="50px"/>
</asp:RadioButtonList>
</itemtemplate>
</asp:TemplateField>数据库中有一字段 DYZT,值只能为 营业,空置, 停用, 歇业 四者其中之一。但是现在数据库中只有营业,空置。
需求:从数据库中读取 DYZT 的值,根据值 让页面上的RadioButtonList中的对应按钮被选中。当用户修改选项之后 点击保存,将对应的修改 写入数据库.最好有具体的代码。谢谢.急!急!急!
if(数据库查出来的字段DYZT=="营业"){
利用FindCotrols找到营业和空置俩个RadioButton然后讲其checked设为true
}最后将其保存在数据库中不就ok了
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
RadioButtonList rbt = e.Item.FindControl("rbtnlist1") as RadioButtonList;
}试试