显示正在加载消息在Asp.net

问题描述:

我想表明我的asp.net网页中的负载指示,而我的GridView被填满数据显示正在加载消息在Asp.net

这是我的aspx页面

<script type="text/javascript" src="Scripts/jsUpdateProgress.js"></script>  
    <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
    <asp:Panel ID="panelUpdateProgress" runat="server" CssClass="updateProgress"> 
     <asp:UpdateProgress ID="UpdateProg1" DisplayAfter="0" runat="server"> 
      <ProgressTemplate> 
       <div style="position: relative; top: 30%; text-align: center;"> 
        <img src="Styles/images/loading.gif" style="vertical-align: middle" alt="Processing" /> 
        Loading... 
       </div> 
      </ProgressTemplate> 
     </asp:UpdateProgress> 
    </asp:Panel> 
    <ajaxToolkit:ModalPopupExtender ID="ModalProgress" runat="server" TargetControlID="panelUpdateProgress" 
     BackgroundCssClass="modalBackground" PopupControlID="panelUpdateProgress" /> 

的一部分(我的代码是基于这个样本weblogs.asp.net/blogs/guillermo/Code/modalExample.zip)

这是我的按钮来调用我的方法

<asp:UpdatePanel ID="updatePanel" runat="server"> 
     <ContentTemplate> 
      <asp:Button ID="btMonth" runat="server" onclick="btMonth_Click" Text="Ver" /> 
     </ContentTemplate> 
    </asp:UpdatePanel> 

这是我的C#我的方法btMonth_Click

protected void btMonth_Click(object sender, EventArgs e) 
{ 
    string query = "select * from table"; 
    SqlDataSource1.SelectCommand = query; 
    gInd.DataSourceID = "SqlDataSource1"; 
} 

的代码,你可以看到,而“加载”指示器出现我要填写一个GridView,但是当我使我的按钮点击btMonth_Click调用该方法,该方法被执行,但我的gridview没有得到填充。如果我删除了我的按钮的asp:UpdatePanel,我的gridview被填满了很好

有什么我失踪了吗?

+0

呼叫按钮事件处理函数 – 2012-07-24 20:26:50

+0

哪里是gridview的网格视图数据绑定的方法?更新面板内部还是外部? – 2012-07-24 20:27:43

+0

让按钮和gridview在同一个UpdatePanel上。 – 2012-07-24 20:28:45

您需要将您的GridVewUpdatePanel的内部,为了部分呈现

如果由于设计原因您不能将您的网格放置在fi首先UpdatePanel,你可以有几个UpdatePanel

欲了解更多信息:

How to work with two update panels on same .aspx page

+0

这对我有用,谢谢! – 2012-07-24 20:36:07

尝试添加:

gInd.DataBind(); 

在btMonth_Click (顺便说一句更好的命名CONVENCION将btnMonth_Click。)

protected void btMonth_Click(object sender, EventArgs e) 
{ 
    string query = "select * from table"; 
    SqlDataSource1.SelectCommand = query; 
    gInd.DataSourceID = "SqlDataSource1"; 
    gInd.DataBind(); 
} 
+0

哎呦,在方法中错字,谢谢 – 2012-07-24 20:35:35