用
if(!this.IsPostBack)
{
}
具体该怎么做呢,我好象没实验成功啊。如果放在DropDownList2_SelectedIndexChanged事件里面的话,这个事件就不会执行了。
if(!this.IsPostBack)
{
}
具体该怎么做呢,我好象没实验成功啊。如果放在DropDownList2_SelectedIndexChanged事件里面的话,这个事件就不会执行了。
调试欢乐多
type_ddl.SelectedValue=="0"
(tyoe_ddl为ID,0为你的ddl默认值可改)
{
//all your code when page load will write here
}
楼主,思考一下,postback是页面回送,如果把代码都写在页面第一次load的时候,就不会有这个问题了的
页面上有一个 Dropdownlist和一个button private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
string[] x={"1","2"};
DropDownList1.DataSource=x;
DropDownList1.DataBind();
}
}
//button的点击事件
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write("1");
}
//dropdownlist的selectindexchanged事件
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Response.Write("2");
} }
}
首先改变dropdownlist的值,此时页面会打出“2”,然后按后退,再按button,此时页面打印出“21",现在我希望它在后退后只打印出”1“,该怎么办呢?