这种下拉列表框效果是如何实现的
这种下拉列表框效果是怎么实现的!
给个列子好吗?
------解决方案--------------------
前台: <asp:DropDownList ID="Drop_duty" runat="server">
</asp:DropDownList>
后台:/// <summary>
/// 绑定分类下拉框
/// </summary>
private void DropTree()
{
Drop_duty.Items.Clear();
Drop_duty.Items.Add(new ListItem("请选择", "0"));
try
{
DataTable dttype = new BLL.cp_newstype().GetList(0, "newst_pid=0 and newst_type=1", "newst_order asc,newst_id desc").Tables[0];
for (int i = 0; i < dttype.Rows.Count; i++)
{
Drop_duty.Items.Add(new ListItem(dttype.Rows[i]["newst_name"].ToString(), dttype.Rows[i]["newst_id"].ToString()));
DataTable dtpid = new BLL.cp_newstype().GetList(0, "newst_pid=" + dttype.Rows[i]["newst_id"].ToString() + " and newst_type=1", "newst_order asc,newst_id desc").Tables[0];
for (int j = 0; j < dtpid.Rows.Count; j++)
{
Drop_duty.Items.Add(new ListItem(" " + "
------解决方案--------------------
--" + dtpid.Rows[j]["newst_name"].ToString(), dtpid.Rows[j]["newst_id"].ToString()));
}
}
}
catch
{
;
}
}
也就是两个for循环!
比如 两级菜单 先帮定第一级 然后for循环 每循环一次把id传给下一个循环 以此类推!
不懂的你可以在问我!
------解决方案--------------------
为什么不看他代码
------解决方案--------------------
给个列子好吗?
------解决方案--------------------
前台: <asp:DropDownList ID="Drop_duty" runat="server">
</asp:DropDownList>
后台:/// <summary>
/// 绑定分类下拉框
/// </summary>
private void DropTree()
{
Drop_duty.Items.Clear();
Drop_duty.Items.Add(new ListItem("请选择", "0"));
try
{
DataTable dttype = new BLL.cp_newstype().GetList(0, "newst_pid=0 and newst_type=1", "newst_order asc,newst_id desc").Tables[0];
for (int i = 0; i < dttype.Rows.Count; i++)
{
Drop_duty.Items.Add(new ListItem(dttype.Rows[i]["newst_name"].ToString(), dttype.Rows[i]["newst_id"].ToString()));
DataTable dtpid = new BLL.cp_newstype().GetList(0, "newst_pid=" + dttype.Rows[i]["newst_id"].ToString() + " and newst_type=1", "newst_order asc,newst_id desc").Tables[0];
for (int j = 0; j < dtpid.Rows.Count; j++)
{
Drop_duty.Items.Add(new ListItem(" " + "
------解决方案--------------------
--" + dtpid.Rows[j]["newst_name"].ToString(), dtpid.Rows[j]["newst_id"].ToString()));
}
}
}
catch
{
;
}
}
也就是两个for循环!
比如 两级菜单 先帮定第一级 然后for循环 每循环一次把id传给下一个循环 以此类推!
不懂的你可以在问我!
------解决方案--------------------
<optgroup label="奔驰">
<option>奔驰A</option>
<option>奔驰B</option>
<option>奔驰C</option>
</optgroup>
为什么不看他代码
------解决方案--------------------