我无法从下拉列表中检索值 [英] iam not able to retreive the value from the dropdownlist

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

问题描述

受保护的无效Page_Load(对象发送者,EventArgs e)
{
Loademployeegeofencee(strUnitNo);
}


私有void Loademployeegeofencee(object strUnitNo)
{
//这里我将值从数据库加载到下拉列表"Superuserid1"
//这很好用

}

受保护的void Superuserid1_SelectedIndexChanged(对象发送者,EventArgs e)
{
字符串st;
st = Superuserid1.SelectedItem.value;

//要执行的代码

}
这里的问题是,当我在st中设置断点时,其显示为null,该值不在st

protected void Page_Load(object sender, EventArgs e)
{
Loademployeegeofencee(strUnitNo);
}


private void Loademployeegeofencee(object strUnitNo)
{
//here i load the value from the database to the dropdownlist "Superuserid1"
//this works fine

}

protected void Superuserid1_SelectedIndexChanged(object sender, EventArgs e)
{
string st;
st=Superuserid1.SelectedItem.value;

//code to be executed

}
the issue here is when i set the break point in st its showing null the value is not coming inside st

推荐答案

中,您只需要绑定数据1st,
不在回发中
所以,试试这个
You have to bind the data 1st only,
not in the postback
so,try this
if (!IsPostBack)
{
 Loademployeegeofencee(strUnitNo);

 }


尝试:
st=Superuserid1.Text.ToString()



或仅



or only

st=Superuserid1.Text


它将正常工作,并为我工作
It will work, and Working for me
void Superuserid1_SelectedIndexChanged(object sender, EventArgs e)
       {
           string s=Superuserid1.SelectedValue;
       }


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

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