如何根据选择在下拉列表中分配值 [英] how to assign a value in dropdownlist based on selection

查看:67
本文介绍了如何根据选择在下拉列表中分配值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据选择在下拉列表中指定值



反馈设计页面如下



设备是什么程度最新Dropdownlist1(优秀/良好/公平)

设备用户友好程度Dropdownlist2(优秀/良好/公平)

到多大程度实用性现实Dropdownlist2(优秀/良好/公平)



例如在Dropdownlist1中如果用户选择要存储在数据库中的优秀均值1值。

类似地,在Dropdownlist2中,如果用户选择要存储在数据库中的良好均值2值。

类似地,在Dropdownlist3中,如果用户选择Fair意味着3值将存储在数据库中。



我怎样才能在asp.net中使用c#。



问候,

narasiman P.

how to assign a value in dropdownlist based on selection

Feedback design page as follows

To What extent equipment is uptodate Dropdownlist1(Excellent/good/Fair)
To what extent equipment is user friendly Dropdownlist2(Excellent/good/Fair)
To What extent were the practicals Realistic Dropdownlist2(Excellent/good/Fair)

for example in Dropdownlist1 if user select the Excellent means 1 value to be store in the database.
similarily, in Dropdownlist2 if user select the good means 2 value to be store in the database.
similarily, in Dropdownlist3 if user select the Fair means 3 value to be store in the database.

for that how can i do in asp.net using c#.

regards,
narasiman P.

推荐答案

如果sql表中的数据类型是int,或者其他什么......那么你必须将它转换成.. int



我用过这段代码:



int userID = convert.toint32(ddluser.selectvalue);



n如果你想选择保存的下拉列表项目那么



这段代码:



ddluser.items.findbyvalue(dr [user]。tostring())。selected = true;







希望这可以帮到你。
if the datatype in sql table is int, or whatever... then u have to convert it into.. int

i'm used this code:

int userID = convert.toint32(ddluser.selectvalue);

n if u want to select the saved item of dropdownlist then

this code:

ddluser.items.findbyvalue(dr["user"].tostring()).selected = true;



Hope this may help u.


你可以尝试通过代码设置下拉列表的值字段,甚至可以设置仅在设计视图中来自列表项值属性的值。



您可以使用的代码



dropdownlist.selectedvalue在数据库中提交值。
you can try and set value field of dropdown list via code or even you can set value from list item value property in design view only.

in code you can use

dropdownlist.selectedvalue to submit the value in the database.


为每个下拉列表项设置'value'并使用Dropdownlist1.SelectedValue
set 'value' to each of your dropdownlist items and use Dropdownlist1.SelectedValue


这篇关于如何根据选择在下拉列表中分配值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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