在数据库中存储复选框状态 [英] store checkbox state in database
本文介绍了在数据库中存储复选框状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望使用gridview
解决方案
http://www.wiseowl.co.uk/blog/s315/bit-true-false.htm [ ^ ]
希望这有帮助...
首先你必须在你的sql server中有一个字段,表示'isChecked'的BIT类型。
然后在你的C#代码中,如果复选框的Checked状态为true,则在一行的'isChecked'字段中插入/更新1 else 0。
< blockquote>你可以在gridview查找控件的帮助下找到一个控件,如
protected void GridView1_RowDataBound( object sender,GridViewRowEventArgs e)
{
CheckBox ch =(CheckBox)Gr idView1.FindControl( 复选框的ID);
if (ch.Checked == true )
{
// 数据库调用
}
else
{
// false数据库调用
}
}
任何查询和信息评论或回复。
I want tick checkbox stored database in true uncheck stored database in false using gridview
解决方案
Peter Leow already has added the solution which you need. A link added below for an clear understanding on how its stored at the DB side.
http://www.wiseowl.co.uk/blog/s315/bit-true-false.htm[^]
Hope this helps...
First you have to have a table with a field say 'isChecked' of BIT type in your sql server.
Then in your C# code, if the Checked state of the checkbox is true then insert/update 1 else 0 into the 'isChecked' field of a row.
you can find a control with the help of gridview find control like thatprotected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { CheckBox ch = (CheckBox)GridView1.FindControl("id of your check box"); if (ch.Checked == true) { //database call here } else { //false database call here } }
for any query and information comment or reply.
这篇关于在数据库中存储复选框状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文