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

问题描述

我按文本框插入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.

推荐答案

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;
 }
}


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

08-30 06:49