如何绑定单选按钮列表.. [英] how to bind radio button list..

查看:92
本文介绍了如何绑定单选按钮列表..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按文本框插入studentname,并通过radiobutton列表值插入currentstatus ..



这是我的radiobuttonlist



i am insert studentname by textbox and currentstatus by radiobutton list value..

this is my radiobuttonlist

<asp:RadioButtonList ID="RadioBtnList1" runat="server" AppendDataBoundItems="true"  RepeatDirection="Horizontal">
                                 <asp:ListItem Text="Active" Value="0" ></asp:ListItem>
                                 <asp:ListItem Text="Deactive" Value="1"></asp:ListItem>
                                 </asp:RadioButtonList>







i需要当我选择任何学生时,如果他在数据库中,那么他的选择是真的当前状态radiobutton list。




i need that when i select any student and if he is in database it makes true his selected current status radiobutton list.

推荐答案

只是一个演示:

Just a demo:
public void PopulateStudent(ID) //your selected student
{
 if (Convert.ToInt32(dr[0]["StudID"]) != 0) // Meaning student is in database
 {
   RadioBtnList1.SelectedValue = dr[0]["StudentStatus"].ToString();
 }
 else
 {
  RadioBtnList1.Items[0].Selected = false;
  RadioBtnList1.Items[1].Selected = false;
 }
}


这篇关于如何绑定单选按钮列表..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆