c# webbrowser 实现网页三级联动下拉选择的问题
webbrowser三级联动下拉选择网页代码是这样的<selectname="ddl_strat_dq1"id="ddl_strat_dq1"><optionvalue=...
webbrowser三级联动 下拉选择
网页代码是这样的
<select name="ddl_strat_dq1" id="ddl_strat_dq1">
<option value="">请选择省</option>
<option value="1">上海</option>
<option value="237">云南</option>
<option value="33784">甘肃</option>
<option value="43919">黑龙江</option>
</select>
<select name="ddl_strat_dq11" id="ddl_strat_dq11">
<option value="">请选择市</option>
</select>
<select name="ddl_strat_dq111" id="ddl_strat_dq111">
<option value="">请选择区</option>
</select>
选择了省过后 才能选市 最后才能选区
请问我要怎么编写才能得出 甘肃省 兰州市 城关区 展开
网页代码是这样的
<select name="ddl_strat_dq1" id="ddl_strat_dq1">
<option value="">请选择省</option>
<option value="1">上海</option>
<option value="237">云南</option>
<option value="33784">甘肃</option>
<option value="43919">黑龙江</option>
</select>
<select name="ddl_strat_dq11" id="ddl_strat_dq11">
<option value="">请选择市</option>
</select>
<select name="ddl_strat_dq111" id="ddl_strat_dq111">
<option value="">请选择区</option>
</select>
选择了省过后 才能选市 最后才能选区
请问我要怎么编写才能得出 甘肃省 兰州市 城关区 展开
3个回答
展开全部
参考:
private void bind(){
SqlConnection conn = db.createConn();
string sqlRent = "select * from Rental";
conn.Open();
SqlCommand cmdRent = new SqlCommand(sqlRent, conn);
SqlDataReader sdrRent=cmdRent.ExecuteReader();
ddl_renting.DataSource = sdrRent;
ddl_renting.DataTextField = "rentalName";
ddl_renting.DataValueField = "rentalId";
ddl_renting.DataBind();
sdrRent.Close();
string sqlCity = "select * from Provience";
SqlCommand cmdCity=new SqlCommand(sqlCity,conn);
SqlDataReader sdrCity = cmdCity.ExecuteReader();
ddl_city.DataSource = sdrCity;
ddl_city.DataTextField = "provienceName";
ddl_city.DataValueField = "provienceId";
ddl_city.DataBind();
sdrCity.Close();
string sqlQuyu = "select * from City where c_id="+ddl_city.SelectedValue;
SqlCommand cmdQuyu = new SqlCommand(sqlQuyu,conn);
SqlDataReader sdrQuyu = cmdQuyu.ExecuteReader();
ddl_quyu.DataSource = sdrQuyu;
ddl_quyu.DataTextField = "cityName";
ddl_quyu.DataValueField = "cityId";
ddl_quyu.DataBind();
sdrQuyu.Close();
string sqlCom = "select * from Community where com_id="+ddl_quyu.SelectedValue;
SqlCommand cmdCom = new SqlCommand(sqlCom,conn);
SqlDataReader sdrCom = cmdCom.ExecuteReader();
ddl_xiaoqu.DataSource = sdrCom;
ddl_xiaoqu.DataTextField = "communityName";
ddl_xiaoqu.DataValueField = "communityId";
ddl_xiaoqu.DataBind();
sdrCom.Close();
conn.Close();
}
protected void ddl_city_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn=db.createConn();
string c_id = ddl_city.SelectedValue;
string sql = "select * from City where c_id="+c_id;
conn.Open();
SqlCommand cmd = new SqlCommand(sql,conn);
SqlDataReader sdr = cmd.ExecuteReader();
ddl_quyu.DataSource = sdr;
ddl_quyu.DataTextField = "cityName";
ddl_quyu.DataValueField = "cityId";
ddl_quyu.DataBind();
sdr.Close();
conn.Close();
}
protected void ddl_quyu_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn = db.createConn();
string c_id = ddl_quyu.SelectedValue;
string sql = "select * from Community where com_id="+c_id;
conn.Open();
SqlCommand cmd = new SqlCommand(sql,conn);
SqlDataReader sdr = cmd.ExecuteReader();
ddl_xiaoqu.DataSource = sdr;
ddl_xiaoqu.DataTextField = "communityName";
ddl_xiaoqu.DataValueField = "communityId";
ddl_xiaoqu.DataBind();
sdr.Close();
conn.Close();
}
private void bind(){
SqlConnection conn = db.createConn();
string sqlRent = "select * from Rental";
conn.Open();
SqlCommand cmdRent = new SqlCommand(sqlRent, conn);
SqlDataReader sdrRent=cmdRent.ExecuteReader();
ddl_renting.DataSource = sdrRent;
ddl_renting.DataTextField = "rentalName";
ddl_renting.DataValueField = "rentalId";
ddl_renting.DataBind();
sdrRent.Close();
string sqlCity = "select * from Provience";
SqlCommand cmdCity=new SqlCommand(sqlCity,conn);
SqlDataReader sdrCity = cmdCity.ExecuteReader();
ddl_city.DataSource = sdrCity;
ddl_city.DataTextField = "provienceName";
ddl_city.DataValueField = "provienceId";
ddl_city.DataBind();
sdrCity.Close();
string sqlQuyu = "select * from City where c_id="+ddl_city.SelectedValue;
SqlCommand cmdQuyu = new SqlCommand(sqlQuyu,conn);
SqlDataReader sdrQuyu = cmdQuyu.ExecuteReader();
ddl_quyu.DataSource = sdrQuyu;
ddl_quyu.DataTextField = "cityName";
ddl_quyu.DataValueField = "cityId";
ddl_quyu.DataBind();
sdrQuyu.Close();
string sqlCom = "select * from Community where com_id="+ddl_quyu.SelectedValue;
SqlCommand cmdCom = new SqlCommand(sqlCom,conn);
SqlDataReader sdrCom = cmdCom.ExecuteReader();
ddl_xiaoqu.DataSource = sdrCom;
ddl_xiaoqu.DataTextField = "communityName";
ddl_xiaoqu.DataValueField = "communityId";
ddl_xiaoqu.DataBind();
sdrCom.Close();
conn.Close();
}
protected void ddl_city_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn=db.createConn();
string c_id = ddl_city.SelectedValue;
string sql = "select * from City where c_id="+c_id;
conn.Open();
SqlCommand cmd = new SqlCommand(sql,conn);
SqlDataReader sdr = cmd.ExecuteReader();
ddl_quyu.DataSource = sdr;
ddl_quyu.DataTextField = "cityName";
ddl_quyu.DataValueField = "cityId";
ddl_quyu.DataBind();
sdr.Close();
conn.Close();
}
protected void ddl_quyu_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn = db.createConn();
string c_id = ddl_quyu.SelectedValue;
string sql = "select * from Community where com_id="+c_id;
conn.Open();
SqlCommand cmd = new SqlCommand(sql,conn);
SqlDataReader sdr = cmd.ExecuteReader();
ddl_xiaoqu.DataSource = sdr;
ddl_xiaoqu.DataTextField = "communityName";
ddl_xiaoqu.DataValueField = "communityId";
ddl_xiaoqu.DataBind();
sdr.Close();
conn.Close();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1。通过ID得到省份的元素,赋值为“兰州市”并调用其onchange事件;
2. 通过timer触发5秒后再找到兰州市的value,赋值并调用其onchange事件;
3.通过timer触发5秒后再找到城关区的value,赋值并调用其onchange事件;
如果还不会的话,发你的URL地址出来,我贴代码给你
2. 通过timer触发5秒后再找到兰州市的value,赋值并调用其onchange事件;
3.通过timer触发5秒后再找到城关区的value,赋值并调用其onchange事件;
如果还不会的话,发你的URL地址出来,我贴代码给你
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
首先你要有全国地区的省市区的列表.选择了省之后根据省筛选出市的列表,然后通过某方式(推荐JQuery)赋值给市的下拉框列表,选完市之后同样的筛选赋值给区.
你可以找一下联动操作的代码看一下.
你可以找一下联动操作的代码看一下.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询