ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Bind (Populate) ASP.Net Repeater in Master Page asynchronously (Async Method) using C#<p>We can use async in master page, please find the code below.</p> <pre class="brush: csharp"> private string connection = ConfigurationManager.ConnectionStrings[&#34;xxxxx&#34;].ConnectionString.ToString(); public async Task GetSomeData() { //Use Async method to get data. DataSet results = await GetDataSetAsync(connection, &#34;Select * from notifications&#34;, null); //Populate once data received. AllNotifications.DataSource = results.Tables[0]; AllNotifications.DataBind(); } public Task&lt;DataSet&gt; GetDataSetAsync(string sConnectionString, string sSQL, params SqlParameter[] parameters) { return Task.Run(() =&gt; { using (SqlConnection newConnection = new SqlConnection(sConnectionString)) using (SqlDataAdapter mySQLAdapter = new SqlDataAdapter(sSQL, newConnection)) { mySQLAdapter.SelectCommand.CommandType = CommandType.Text; if (parameters != null) { mySQLAdapter.SelectCommand.Parameters.AddRange(parameters); } DataSet myDataSet = new DataSet(); mySQLAdapter.Fill(myDataSet); return myDataSet; } }); }</pre> <p>and in page_load of masterpage:</p> <pre class="brush: csharp">if (!IsPostBack) { Page.RegisterAsyncTask(new PageAsyncTask(GetSomeData)); }</pre> <p><strong>Note: </strong>We have to use <strong>async="true"</strong> in all child pages for this code to work.</p>https://www.aspforums.net:443/Threads/446769/Bind-Populate-ASPNet-Repeater-in-Master-Page-asynchronously-Async-Method-using-C/https://www.aspforums.net:443/Threads/446769/Bind-Populate-ASPNet-Repeater-in-Master-Page-asynchronously-Async-Method-using-C/Fri, 23 Aug 2019 02:30:06 GMT