请问我这个程序里ListBox的值怎么取出来?

chinayinyue 2005-11-18 05:15:09
//为ListBox2绑定数据
string sql = "select truename,FingerPrintNo from FingerPrint_MessageTable where Enabled=1 and DepartMent='"+ListBox1.SelectedValue.ToString()+"'" ;
SqlConnection Connection = new SqlConnection(ConfigurationSettings.AppSettings["Conn_FingerKeeper"]);
SqlCommand thisCommand = new SqlCommand ( sql,Connection );

try
{
thisCommand.Connection.Open();//打开数据库连接
SqlDataReader dr = thisCommand.ExecuteReader();//执行SQL语句,并返回DataReader对象
while(dr.Read())//循环读取结果集并加入ListBox2
{
//ListBox1.Items.Add(dr["truename"].ToString());
ListBox2.Items.Add(new ListItem(dr["truename"].ToString(),dr["FingerPrintNo"].ToString()));
}
dr.Close();
}
catch(SqlException ex)
{
Label1.Text = ex.ToString();
}
finally
{
thisCommand.Connection.Close();
}

====================================================================
这里的ListBox2.SelectedValue.ToString()是不能显示出来的。
请问用什么方式可以显示出来?我都快疯了!5555555555~~~~~~~~~~~~~~~~~~~~~~


&*%^$#&^$(*#&%(*#$%^(*$W&#%^)(*##@@#@#@$@%#
...全文
142 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
swordragon 2005-11-18
  • 打赏
  • 举报
回复
使用
ListBox2.SelectedValue.ToString()
前,必须首先选择一个。
孟子E章 2005-11-18
  • 打赏
  • 举报
回复
WinForm应该是不难的吧
Anders_lt 2005-11-18
  • 打赏
  • 举报
回复
你想在哪里显示?
孟子E章 2005-11-18
  • 打赏
  • 举报
回复
Request.Form["ListBox2"]

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧