radiobuttionlist asp.net将数据发送到数据库sql [英] radiobuttionlist asp.net send data to data base sql
本文介绍了radiobuttionlist asp.net将数据发送到数据库sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
性别值(如男性和女性),并以asp.net代码将其发送到数据库,代码为c#
gender values like male female and send it to data base in asp.net code behaind c#
<td><asp:RadioButtonList ID="Radiobuttonlist1" runat="server">
<asp:ListItem>male</asp:ListItem>
<asp:ListItem>female</asp:ListItem>
</asp:RadioButtonList></td>
</tr>
.cs
cmd = new sqlcommand(插入table_name值(''" + radiobuttonlist1.selecteditem.text +'',con);
cmd.ExecuteNonQuery();
像这样可能不是
.cs
cmd=new sqlcommand(insert into table_name values(''"+radiobuttonlist1.selecteditem.text+"'',con);
cmd.ExecuteNonQuery();
like this possible are not
推荐答案
不要将文本值发送到数据库...您可以将数字发送到数据库,例如
男性-0
女用-1
希望这有助于
Dont send text values to database... u can send numeric to database like
For Male - 0
For Female - 1
Hope this helps
以相同的方式尝试
try in the same way
<asp:RadioButtonList ID="rb_Isfresher" RepeatDirection="Horizontal" runat="server"
OnSelectedIndexChanged="rb_Isfresher_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Text="Yes" Value="0" Selected="True">
<asp:ListItem Text="No" Value="1">
//在
后面的代码中
//in the code behind
Boolean strIsFresher ;
if (rb_Isfresher.SelectedValue == "1")
{
strIsFresher = true;
}
else
{
strIsFresher = false;
}
//将布尔值发送到数据库
}
// Send Boolean value to the Database
这篇关于radiobuttionlist asp.net将数据发送到数据库sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文