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.Display record greater than or equal to current date in ASP.Net DataList using C# and VB.Net<p>Hey <a class="username" rel="chetan">chetan</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;asp:DataList ID=&#34;DataList1&#34; runat=&#34;server&#34; RepeatDirection=&#34;Horizontal&#34; RepeatColumns=&#34;1&#34;&gt; &lt;ItemTemplate&gt; &lt;div style=&#34;border: 2px solid #ccc;&#34;&gt; &lt;b&gt;EventId:&lt;/b&gt; &lt;asp:Label ID=&#34;Label1&#34; Text=&#39;&lt;%# Eval(&#34;EventId&#34;) %&gt;&#39; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;b&gt;Event Name:&lt;/b&gt; &lt;asp:Label ID=&#34;Label2&#34; Text=&#39;&lt;%# Eval(&#34;EventName&#34;) %&gt;&#39; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;b&gt;Upcoming Event Date:&lt;/b&gt; &lt;asp:Label ID=&#34;Label3&#34; Text=&#39;&lt;%#Eval(&#34;EventDate&#34;,&#34;{0:dd/MM/yyyy}&#34;) %&gt;&#39; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;/div&gt; &lt;/ItemTemplate&gt; &lt;/asp:DataList&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Configuration; using System.Data.SqlClient; using System.Data;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Data.SqlClient Imports System.Data</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this.BindListView(); } } private void BindListView() { string constr = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = &#34;SELECT EventId, EventName, EventDate FROM EventTest WHERE EventDate &gt; = @EventDate&#34;; cmd.Connection = con; cmd.Parameters.AddWithValue(&#34;@EventDate&#34;, DateTime.Now.ToString(&#34;yyy-MM-dd&#34;)); using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { DataTable dt = new DataTable(); sda.Fill(dt); DataList1.DataSource = dt; DataList1.DataBind(); } } } }</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 Me.BindListView() End If End Sub Private Sub BindListView() Dim constr As String = ConfigurationManager.ConnectionStrings(&#34;constr&#34;).ConnectionString Using con As SqlConnection = New SqlConnection(constr) Using cmd As SqlCommand = New SqlCommand() cmd.CommandText = &#34;SELECT EventId, EventName, EventDate FROM EventTest WHERE EventDate &gt; = @EventDate&#34; cmd.Connection = con cmd.Parameters.AddWithValue(&#34;@EventDate&#34;, DateTime.Now.AddYears(-60)) Using sda As SqlDataAdapter = New SqlDataAdapter(cmd) Dim dt As DataTable = New DataTable() sda.Fill(dt) DataList1.DataSource = dt DataList1.DataBind() End Using End Using End Using End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://imgur.com/2c26EEV.jpg" alt="" width="269" height="367" /></p>https://www.aspforums.net:443/Threads/158405/Display-record-greater-than-or-equal-to-current-date-in-ASPNet-DataList-using-C-and-VBNet/https://www.aspforums.net:443/Threads/158405/Display-record-greater-than-or-equal-to-current-date-in-ASPNet-DataList-using-C-and-VBNet/Wed, 26 Dec 2018 03:53:57 GMTDisplay record greater than or equal to current date in ASP.Net DataList using C# and VB.Net<p>Hi Sir,</p> <p>i have used the following query and it worked.</p> <pre class="brush: sql">sqlnews = &#34;SELECT * FROM ogpe_exhibitions where status=1 and DATE(start_date) &gt; DATE(NOW()) order by start_date&#34;;</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/158405/Display-record-greater-than-or-equal-to-current-date-in-ASPNet-DataList-using-C-and-VBNet/https://www.aspforums.net:443/Threads/158405/Display-record-greater-than-or-equal-to-current-date-in-ASPNet-DataList-using-C-and-VBNet/Wed, 26 Dec 2018 04:24:53 GMT