showModalDialog 出来的窗口怎么在Page_Load绑定DBGrid在打开第二次数据不更新和第一次的数据库一样,绑定代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string Str_Build="select * from MenuTree where Depth='1'";
DataBinder(Str_Build);
}
private void DataBinder(string SQLText)
{
Dg_ChooseMenu.DataSource = FunClass.SelectToDataSet(SQLText);
Dg_ChooseMenu.DataBind();
}
//获取查询的数据集
public DataSet SelectToDataSet(string SQLText)
{
ConClass.Open();
SqlCommand Cmd_Select = new SqlCommand(SQLText,ConClass.ADOCon);
SqlDataAdapter Dadp_Select = new SqlDataAdapter();
Dadp_Select.SelectCommand = Cmd_Select;
DataSet DataSet_Return = new DataSet();
try
{
Dadp_Select.Fill(DataSet_Return);
}
catch
{
return null;
}
finally
{
ConClass.Close();
}
return DataSet_Return;
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string Str_Build="select * from MenuTree where Depth='1'";
DataBinder(Str_Build);
}
private void DataBinder(string SQLText)
{
Dg_ChooseMenu.DataSource = FunClass.SelectToDataSet(SQLText);
Dg_ChooseMenu.DataBind();
}
//获取查询的数据集
public DataSet SelectToDataSet(string SQLText)
{
ConClass.Open();
SqlCommand Cmd_Select = new SqlCommand(SQLText,ConClass.ADOCon);
SqlDataAdapter Dadp_Select = new SqlDataAdapter();
Dadp_Select.SelectCommand = Cmd_Select;
DataSet DataSet_Return = new DataSet();
try
{
Dadp_Select.Fill(DataSet_Return);
}
catch
{
return null;
}
finally
{
ConClass.Close();
}
return DataSet_Return;
}
Context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
试试。
不知有没有理解错你的问题意思:)
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string Str_Build="select * from MenuTree where Depth='1'";
DataBinder(Str_Build);
}执行了 page_load 事件,但在打开这个页面时:page_load就没有执行怎么回事
string Str_Build="select * from MenuTree where Depth='1'";
DataBinder(Str_Build);
这串语句最好放在if (!IsPostback)里面
可以了,但我没有看明白这句话的意思
{
if(!IsPostBack){
string Str_Build="select * from MenuTree where Depth='1'";
DataBinder(Str_Build);}
}