请问我这个程序里ListBox的值怎么取出来?
//为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&#%^)(*##@@#@#@$@%#