| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 1024 人关注过本帖
标题:DropDownList问题
取消只看楼主 加入收藏
上炕不脱鞋
Rank: 1
等 级:新手上路
威 望:1
帖 子:332
专家分:0
注 册:2006-3-19
收藏
 问题点数:0 回复次数:1 
DropDownList问题
如何确定DropDownList里面的所选的内容?然后把所选的内容当作查询条件啊?

public bool FillDropDownList(DropDownList ddl,string sTmp)
{
try
{
SqlCommand cmd=new SqlCommand(sTmp,con);
SqlDataReader sdr=cmd.ExecuteReader();
ddl.Items.Clear();
while(sdr.Read())
{
ListItem li = new ListItem(sdr[0].ToString());
ddl.Items.Add(li);
}
sdr.Close();
return true;
}
catch(Exception e)
{
e.Message.ToString();
return false;
}
}
这个是.cs
string str="select DeptName from DeptInfo";
if(odb.FillDropDownList(cx02,str))
{
}
else
{
Response.Write("<script>alert('发生错误!')</script>");
}

这个调用

if(cx01.Text=="" && cx02.SelectedItem.Text!="" && cx03.Text=="" && cx04.Text=="" && cx05.Text=="" && cx06.Text=="" && cx07.Text=="")
{
string str2="select StoDate,StoPaID,StoName,StoVi,StoPaMo,StoPayout,StoInMo,StoEsMo,StoCoMo,StoAdDe,StoPurve,StoStPh from StoPactInfo where StoAdDe like '"+cx02.SelectedItem.Text.ToString().Trim()+"'";
odb.Search(DataGrid1,str2);

这个是做为条件查询。 兄弟们帮我看看我写那里错了,现在的错误是比如DropDownList里在数据库里读出来2个,items分别是111、222,我选择222的时候虽然DropDownList显示的是222,可是点查询的时候还是根据111为条件查询的。

新建的群(C#):23384106 验证注明
2006-12-04 16:13
上炕不脱鞋
Rank: 1
等 级:新手上路
威 望:1
帖 子:332
专家分:0
注 册:2006-3-19
收藏
得分:0 
晕 我知道怎么回事了
我没加!Page.IsPostBack

新建的群(C#):23384106 验证注明
2006-12-04 16:15
快速回复:DropDownList问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013151 second(s), 8 queries.
Copyright©2004-2025, BC-CN.NET, All Rights Reserved