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

问题描述

受保护的无效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

推荐答案

if (!IsPostBack)
{
 Loademployeegeofencee(strUnitNo);

 }


st=Superuserid1.Text.ToString()



或仅



or only

st=Superuserid1.Text


void Superuserid1_SelectedIndexChanged(object sender, EventArgs e)
       {
           string s=Superuserid1.SelectedValue;
       }


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

09-12 03:44