当用户点击DropDownList33选择了出租车司机后 为啥DropDownList33.SelectedValue 还是 "个人用户"? 谢谢指正!
protected void SelectiveType()
{
if (DropDownList33.SelectedValue == "个人用户")
{
SerPanel(3);
}
if (DropDownList33.SelectedValue == "出租车司机")
{
SerPanel(4);
}
if (DropDownList33.SelectedValue == "职业司机")
{
SerPanel(5);
}
if (DropDownList33.SelectedValue == "个体运输")
{
SerPanel(6);
}
if (DropDownList33.SelectedValue == "单位用户")
{
SerPanel(7);
}
}
protected void SelectiveType()
{
if (DropDownList33.SelectedValue == "个人用户")
{
SerPanel(3);
}
if (DropDownList33.SelectedValue == "出租车司机")
{
SerPanel(4);
}
if (DropDownList33.SelectedValue == "职业司机")
{
SerPanel(5);
}
if (DropDownList33.SelectedValue == "个体运输")
{
SerPanel(6);
}
if (DropDownList33.SelectedValue == "单位用户")
{
SerPanel(7);
}
}
SelectedValue是Item对应的值
在Page_Load中绑定数据时:
if(!IsPostBack)
{
//绑定DropDownList数据
}
if(!IsPostBack)
{
//绑定DropDownList数据
}会使数据回滚的 当然永远只显示第一个 “个人用户”
if(!IsPostBack)
{
}
{
//DropDownList33绑定数据
DropDownList33.DataSource=ds;
DropDownList33.DataValueField="id";
DropDownList33.DataTextField="name";
DropDownList33.DataBind();
}
再DropDownList33.SelectedValue
{
//DropDownList33绑定数据
DropDownList33.DataSource=ds;
DropDownList33.DataValueField="id";
DropDownList33.DataTextField="name";
DropDownList33.DataBind();
}然后在做判断...
{
//DropDownList33绑定数据
DropDownList33.DataSource=ds;
DropDownList33.DataValueField="id";
DropDownList33.DataTextField="name";
DropDownList33.DataBind();
}
就该注意selectedtext和selectedvalue区别