0

In asp.net ajax, is there any control that indicate the user, wait processing is going on ?. i have to display any animation.

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();

}

1 Answer 1

2

You can use the UpdateProgress control to achieve this. You can show anything inside the UpdateProgess container when any AJAX postback occurs. Look at the example below:

<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>

Use the table in your 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();

}
Sign up to request clarification or add additional context in comments.

2 Comments

When i bind a data to gridview it is not showing the gridview. i write code to bind the datba to gridview in button click event. it is not showing gridview.
@Suryasasidhar did you try to call dataGrid.DataBind()? I have updated the code above. Please take a look

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.