<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中的对应按钮被选中。当用户修改选项之后 点击保存,将对应的修改 写入数据库.最好有具体的代码。谢谢.急!急!急!

解决方案 »

  1.   

    其实这个很简单的就是在后台判断一下,
    if(数据库查出来的字段DYZT=="营业"){
        利用FindCotrols找到营业和空置俩个RadioButton然后讲其checked设为true
    }最后将其保存在数据库中不就ok了
      

  2.   

    关键是  FindControl查找不到,我在GridView2_RowDataBound 方法中 用 RadioButtonList rbt = e.Row.FindControl("rbtnlist1") as RadioButtonList;  查找 结果 rbt 为null 求教.急!
      

  3.   


     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
    RadioButtonList rbt = e.Item.FindControl("rbtnlist1") as RadioButtonList;
                }试试
      

  4.   

    我用得是 GridView 在GridView2_RowDataBound 方法中  用e 点 item 根本点不出来
      

  5.   

    GridView.Rows[行索引].Cells[列索引].Text //获取几行几列之后再findControl试试