我想在单击按钮时填充一个位于更新面板内的 Gridview。目前,gridview 正在被填充,但没有显示在屏幕上。我错过了什么?下面是我正在使用的代码:
public delegate void BindGrid_Delegate();
protected void btnSearch_Click(object sender, EventArgs e)
{
try
{
// databind of all the controls
BindGrid_Delegate bd = new BindGrid_Delegate(BindGrid);
IAsyncResult ar = bd.BeginInvoke(null, null); //invoking the method
}
catch (Exception ex)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PageException", "alert('" + ex.Message + "');", true);
}
}
private void BindGrid()
{
try
{
DataSet ResultDataSet = GetData();
gvShowResult.DataSource = ResultDataSet;
gvShowResult.DataBind();
UpdatePanel2.Update();
}
catch (Exception ex)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PageException", "alert('" + ex.Message + "');", true);
}
}
更新面板的更新模式是有条件的。我会很感激任何帮助。