我有通過把代碼
(TabContainer1_ActiveTabChanged(TabContainer1, null);)
線在Page_Load
事件,而不是在!IsPostback
事件解決
protected void Page_Load(object sender, EventArgs e)
Page.Title = ConfigurationManager.AppSettings["PageTitle"].ToString().Trim() + " Project Type";
if (!IsPostBack)
{
if (Request.Params["stidx"] != null && Request.Params["stidx"].ToString().Trim() != "")
{
if (Request.Params["stidx"].ToString().Trim() == "0") //have to make project type selected in left
{
NullAllDate_Except_ProjectType();
TabContainer1.ActiveTabIndex = 0;
LeftBar.var_data_to_show = "";
}
else if (Request.Params["stidx"].ToString().Trim() == "1") //have to make Modules selected in left
{
NullAllDate_Except_Module();
TabContainer1.ActiveTabIndex = 1;
LeftBar.var_data_to_show = "";
}
else if (Request.Params["stidx"].ToString().Trim() == "2") //have to make Activity selected in left
{
NullAllDate_Except_Activity();
TabContainer1.ActiveTabIndex = 2;
LeftBar.var_data_to_show = "";
}
else if (Request.Params["stidx"].ToString().Trim() == "3") //have to make Systems selected in left
{
NullAllDate_Except_Systems();
TabContainer1.ActiveTabIndex = 3;
LeftBar.var_data_to_show = "";
}
else if (Request.Params["stidx"].ToString().Trim() == "4") //have to make Module Headers selected in left
{
NullAllDate_Except_ModuleHeaders();
TabContainer1.ActiveTabIndex = 4;
LeftBar.var_data_to_show = "";
}
else
{
NullAllDate_Except_ProjectType();
LeftBar.var_data_to_show = "";
}
}
else
{
NullAllDate_Except_ProjectType();
LeftBar.var_data_to_show = "";
}
}
if (IsPostBack)
{
if (MyScriptManager.IsInAsyncPostBack)
{
//LeftBar.var_data_to_show = true;
LeftBar.var_data_to_show = GetModuleName(TabContainer1.ActiveTabIndex.ToString());
}
}
TabContainer1_ActiveTabChanged(TabContainer1, null); //this is required here, otherwise onrow databound is not working on !Postback
}