2011-10-26 69 views
0

在asp.net ajax中,是否有任何控件指示用戶,等待處理正在進行? 我必須顯示任何動畫。在Asp.Net ajax控件?

protected void Button1_Click(object sender, EventArgs e) 
{ 
    //Thread.Sleep(1500); 


    string sqr = "select * from Pra_Region"; 
    da = new SqlDataAdapter(sqr, con); 
    ds = new DataSet(); 
    da.Fill(ds); 
    grdProduct.Visible = true; 
    grdProduct.DataSource = ds; 
    grdProduct.DataBind(); 

} 

回答

2

您可以使用UpdateProgress控件來實現此目的。當發生任何AJAX postback時,您可以在UpdateProgess容器內顯示任何內容。請看下面的例子:

<script runat="server"> 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
     Thread.Sleep(200); 
     tt.InnerText = DateTime.Now.ToShortTimeString(); 
     grid.DataSource = new List<object> 
           { 
            new {Name = "Munim", Age = 2, Time = DateTime.Now.ToShortTimeString()}, 
            new {Name = "Rashim", Age = 3, Time = DateTime.Now.ToShortTimeString()}, 
            new {Name = "Robin", Age = 25, Time = DateTime.Now.ToShortTimeString()} 
           }; 
     grid.DataBind(); 
    } 
</script> 

<form id="form1" runat="server"> 
<asp:ScriptManager runat="server" ID="sm"> 
</asp:ScriptManager> 
<div> 
    <asp:UpdatePanel runat="server" ID="UpdPnl1" UpdateMode="Conditional"> 
     <ContentTemplate> 
      <asp:DataGrid runat="server" ID="grid"></asp:DataGrid> 
      <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="click" /> 
      <div id="tt" runat="server"> 
      </div> 
     </ContentTemplate> 
    </asp:UpdatePanel> 
    <asp:UpdateProgress ID="updQuoteProgress" runat="server" AssociatedUpdatePanelID="UpdPnl1" 
     DisplayAfter="0"> 
     <ProgressTemplate> 
      Loading...</ProgressTemplate> 
    </asp:UpdateProgress> 
</div> 
</form> 

使用表中你DataSet

protected void Button1_Click(object sender, EventArgs e) 
{ 
    //Thread.Sleep(1500); 


    string sqr = "select * from Pra_Region"; 
    da = new SqlDataAdapter(sqr, con); 
    ds = new DataSet(); 
    da.Fill(ds); 
    grdProduct.Visible = true; 
    grdProduct.DataSource = ds.Tables[0]; 
    grdProduct.DataBind(); 

} 
+0

當我綁定數據到GridView控件它沒有顯示GridView的。我編寫的代碼將按鈕單擊事件中的datba綁定到gridview。它不顯示gridview。 –

+0

@Suryasasidhar是否嘗試調用'dataGrid.DataBind()'?我已經更新了上面的代碼。請看看 –

+0

你會顯示代碼 –