如何在数据库中保存Chechbox值 [英] How Do I Save Chechbox Value In Database

查看:79
本文介绍了如何在数据库中保存Chechbox值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网页中,我有一个复选框(状态)。如果检查checbox状态是1.这1将存储在Db中,如果未选中复选框,状态将为0

In my webpage i have one Checkbox(status).if checbox is checked status is 1.this 1 will be stored in Db and if checkbox is not checked status will be 0

推荐答案

首先你必须创建一个数据库表,并将列名命名为Staus ..

然后在代码后面写这个,



if(Checkbox(status).Checked == true)

User.Status = 1;

else

User.Status = 0;



此处用户是类的对象,用于设置Property以将值插入数据库
First u have to create a DB table and named the column name as Staus..
then write this on code behind,

if (Checkbox(status).Checked == true)
User.Status = 1;
else
User.Status = 0;

here User is the the object of the class for setting the Property to insert the value in to database


int status = 0;

if(Checkbox.Checked == true)

状态= 1;

其他

状态= 0;



u可以将此值存储到数据库中
int status =0;
if (Checkbox.Checked == true)
Status = 1;
else
Status = 0;

u can store this value into database


这篇关于如何在数据库中保存Chechbox值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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