首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

DropDownList中使用Items 集合分别邦定了A、B、C几项. 请问以下有关问题?谢

2011-12-27 
DropDownList中使用Items 集合分别邦定了A、B、C几项. 请教以下问题?谢~DropDownList中使用Items集合分别邦

DropDownList中使用Items 集合分别邦定了A、B、C几项. 请教以下问题?谢~
DropDownList中使用Items   集合分别邦定了A、B、C几项.     然后再拖一个Button出来.

当选择A时   点Button查询把数据库里面的资料查询到DataGrid上.   当选择B时点击Button把B里面的资料取到DataGrid上.

主要是当我选择A时,Button怎么知道我选择的是A   ?     这里是要怎么做判断.     谢谢!



[解决办法]
DropDownList.SelectValue
[解决办法]
string strValue = DropDownList1.SelectValue
[解决办法]
strSQL = "select * from 表 where 字段= ' "+ strValue+ " ' ";
[解决办法]
protected void Button1_Click(object sender, EventArgs e)
{
string chs;
chs=DropDownList1.SelectedItem.ToString(); //ddl的内容
//chs = DropDownList1.SelectedValue.ToString();//ddl的值
}

[解决办法]
private void DDLBut_Click(object sender, System.EventArgs e)
{

if(DDList.SelectedValue== "A ")
{
select * from A
绑定

}
if(DDList.SelectedValue== "B ")
{
select * from B
绑定
}

}
[解决办法]
private void DDLBut_Click(object sender, System.EventArgs e)
{

string chsValue;
string chsText;
chsValue=DDList.SelectedItem.Value.ToString();//DropDownList的Value
chsText=DDList.SelectedItem.Text.ToString();//DropDownList的Text
//。。。爱查什么查什么去吧.
}
[解决办法]
首先确定你的 DDL 绑定 的是什么
<asp:dropdownlist id= "ddl " runat= "server " datatextfield = "Name " datavaluefield= "ID "> </asp:dropdownlist>

id 列是 SelectValue Name列是SelectText
再试试
[解决办法]
button1_click(^)
{
string strCondition = ddl.selectedvalue;
if(strCondition == "A ")
{
...查询a
}
else if(strCondition == "B ")
{
...查询b
}
...
}

热点排行