从下拉列表中选择启用或禁用时出错 [英] error while selecting enable or disable from dropdownlist

查看:131
本文介绍了从下拉列表中选择启用或禁用时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个下拉列表中,两个名称一个是启用,第二个是禁用

然后列中的列类型然后应该在查询中如果启用是选择那么它应该取1否则为0





dropdownlist1.selectedvalue.tosting();

无效。



错误是 - 消息245,级别16,状态1,行1

转换varchar值时转换失败''启用' '到数据类型位。

In one drop down list two name one is Enable and second Is disable
then the type of column in bit then what should be in query that if enabled is select then it should take 1 otherwise 0


dropdownlist1.selectedvalue.tosting ();
is not working .

error is--Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value ''Enable'' to data type bit.

推荐答案

试试这个:



try this:

int i = DropDownList1.SelectedIndex;





int i只是一个变量如果需要,请将数据库列名称放在此处



int i is just a variable put database column name here if requried


设置的值>启用= 0 禁用= 1 并将数据类型 int



谢谢
Set the value of Enable=0 and Disable=1 and put the datatype int.

Thanks


这篇关于从下拉列表中选择启用或禁用时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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