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.Refresh single Column in ASP.Net DataList on Button Click using C# and VB.Net<p>Hi&nbsp;micah,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;asp:ScriptManager runat=&#34;server&#34; /&gt; &lt;asp:DataList ID=&#34;dlDetails&#34; runat=&#34;server&#34;&gt; &lt;ItemTemplate&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt; Id &lt;/th&gt; &lt;th&gt; Name &lt;/th&gt; &lt;th&gt; Country &lt;/th&gt; &lt;th&gt; Time &lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:Label ID=&#34;lblId&#34; Text=&#39;&lt;%# Eval(&#34;Id&#34;)%&gt;&#39; runat=&#34;server&#34; /&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:Label ID=&#34;lblName&#34; Text=&#39;&lt;%# Eval(&#34;Name&#34;)%&gt;&#39; runat=&#34;server&#34; /&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:Label ID=&#34;lblCountry&#34; Text=&#39;&lt;%# Eval(&#34;Country&#34;)%&gt;&#39; runat=&#34;server&#34; /&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:UpdatePanel ID=&#34;UpdatePanel1&#34; runat=&#34;server&#34; UpdateMode=&#34;Conditional&#34;&gt; &lt;ContentTemplate&gt; &lt;asp:Label ID=&#34;lblTime&#34; Text=&#39;&lt;%# DateTime.Now%&gt;&#39; runat=&#34;server&#34; /&gt; &lt;asp:Button ID=&#34;Button1&#34; Text=&#34;Refresh&#34; runat=&#34;server&#34; OnClick=&#34;Refresh&#34; /&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID=&#34;Button1&#34; EventName=&#34;Click&#34; /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/ItemTemplate&gt; &lt;/asp:DataList&gt;&nbsp;</pre> <p><strong><span style="text-decoration: underline;">Namespaces</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Data</pre> <p><strong><span style="text-decoration: underline;">Code</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { BindDataList(); } } private void BindDataList() { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[3] { new DataColumn(&#34;Id&#34;, typeof(int)), new DataColumn(&#34;Name&#34;, typeof(string)), new DataColumn(&#34;Country&#34;,typeof(string)) }); dt.Rows.Add(1, &#34;John Hammond&#34;, &#34;United States&#34;); dt.Rows.Add(2, &#34;Mudassar Khan&#34;, &#34;India&#34;); dt.Rows.Add(3, &#34;Suzanne Mathews&#34;, &#34;France&#34;); dt.Rows.Add(4, &#34;Robert Schidner&#34;, &#34;Russia&#34;); dlDetails.DataSource = dt; dlDetails.DataBind(); } protected void Refresh(object sender, EventArgs e) { (((sender as Button).NamingContainer as DataListItem).FindControl(&#34;lblTime&#34;) as Label).Text = DateTime.Now.ToString(); }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not Me.IsPostBack Then BindDataList() End If End Sub Private Sub BindDataList() Dim dt As DataTable = New DataTable() dt.Columns.AddRange(New DataColumn(2) { New DataColumn(&#34;Id&#34;, GetType(Integer)), New DataColumn(&#34;Name&#34;, GetType(String)), New DataColumn(&#34;Country&#34;, GetType(String))}) dt.Rows.Add(1, &#34;John Hammond&#34;, &#34;United States&#34;) dt.Rows.Add(2, &#34;Mudassar Khan&#34;, &#34;India&#34;) dt.Rows.Add(3, &#34;Suzanne Mathews&#34;, &#34;France&#34;) dt.Rows.Add(4, &#34;Robert Schidner&#34;, &#34;Russia&#34;) dlDetails.DataSource = dt dlDetails.DataBind() End Sub Protected Sub Refresh(ByVal sender As Object, ByVal e As EventArgs) TryCast((TryCast((TryCast(sender, Button)).NamingContainer, DataListItem)).FindControl(&#34;lblTime&#34;), Label).Text = DateTime.Now.ToString() End Sub</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/pOHXrkk.gif" alt="" /></span></strong></p>https://www.aspforums.net:443/Threads/860690/Refresh-single-Column-in-ASPNet-DataList-on-Button-Click-using-C-and-VBNet/https://www.aspforums.net:443/Threads/860690/Refresh-single-Column-in-ASPNet-DataList-on-Button-Click-using-C-and-VBNet/Mon, 10 Dec 2018 05:17:20 GMT