怎么给HTML<Select>标签赋值
我找的纯JS三级联动用的是HTML的<Select>标签,现在通过的 string a1 = Request.Form["s_province"].Trim();
string a2 = Request.Form["s_city"].Trim();
string a3 = Request.Form["s_county"].Trim();从页面取到了省市区的地址,存进了数据库,我要修改了,我从数据库取出了省市区的值,放不进<Select>标签,怎么弄的啊
string ID = e.CommandArgument.ToString();
Label22.Text = ID;
DataTable dt = Sql.SqlHelp.GetTable("select * from Travelrequest where ID=" + ID);
TextBox2.Text = dt.Rows[0]["BeginTime"].ToString();
TextBox3.Text = dt.Rows[0]["EndTime"].ToString();
TextBox1.Text = dt.Rows[0]["Travelday"].ToString();
DropDownList1.SelectedIndex = -1;
DropDownList1.Items.FindByValue(dt.Rows[0]["KindID"].ToString()).Selected = true;
TextBox4.Text = dt.Rows[0]["Reason"].ToString();
string a1 = dt.Rows[0]["s_province"].ToString();
a1要怎么赋值给<Select>,我不会JS的,请高手把详细过程写下,应该也就1行代码吧?
------解决方案--------------------
a1 要设置成select的默认值吗?
function setSelect(s)
{
sl = document.getElementById("selectID")
for(i=0;i<sl.options.length;i++)
{
if(sl.options[i].value==s) sl.options[i].selected=true
}
}
然后后台代码调用
Page.ClientScript.RegisterStartupScript(Page.GetType(),"js","setSelect('"+a1 +"')",true)