数据库中的下拉列表值 [英] dropdown list value in database

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

问题描述

我正在写这样的字符串:

I am writing the string like this:

string qry = "Insert into SchoolBranch (BranchCode,City,State,Country,SchoolCode) values (''"+Sbranchcode.Text+"'',''"+SbranchCity.Text+"'',''"+Sbranhstate.Text+"'',''"+SbranchCountry.Text+"'',''"+BSchoolCode.SelectedItem+"'')";
        BusinessLogic.executqry(qry);


但是它始终被选择为0索引值...所以您可以提供正确的解决方案.


but it is selected only 0 index value all the time...so can you give the right solutions.

推荐答案

我将您的下拉列表绑定在!postBack事件中

I thing You Bind the Dropdown in !postBack Event

in Page Load Event

if(!ispostback)
{
   // Bind your Dropdown
}


然后尝试执行Queryyy


then Try to Execute Queryyy


尝试这个
如果您的下拉列表仅包含Schoolcode作为显示成员,则只需使用代码
try this
if your Drop Down list contains only the Schoolcode as the display member,simply use the code,
string qry = "Insert into SchoolBranch (BranchCode,City,State,Country,SchoolCode) values ('"+Sbranchcode.Text+"','"+SbranchCity.Text+"','"+Sbranhstate.Text+"','"+SbranchCountry.Text+"','"+BSchoolCode.Text+"')";
        BusinessLogic.executqry(qry);




您只需使用组合框的Text属性即可获得组合框的选定文本值.

例如:




You can get the selected text value of a combo box by simply using the Text property of Combo box.

eg:

string s=cmbComboBox.Text;


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

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