我的sql数据库中有一个名为“WEB_SEL_SECURITY_QUESTIONS”的存储过程,它返回一个表,如下所示.
SEQURITY_QUESTIONS_KEY,KEYCODE,QUESTION
我需要填充一个html选择框,其中包含我从执行上述过程中获得的问题列表.
这就是我尝试过的
String s = ConfigurationManager.ConnectionStrings["ConnectionString2"].ToString();
SqlConnection con = new SqlConnection(s);
con.Open();
SqlDataAdapter myAdepter = new SqlDataAdapter("WEB_SEL_SECURITY_QUESTIONS", con);
myAdepter.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
myAdepter.Fill(ds, "WEB_SEL_SECURITY_QUESTIONS");
String questions = ds.Tables["WEB_SEL_SECURITY_QUESTIONS"].Rows[]["QUESTION"].ToString();
securityQuestion1.DataSource = questions;
securityQuestion1.DataBind();
但是这只用一条记录填充选择框,它生成列表项,每个列表项只有一个字符,只有第一个记录.