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 only Date in GridView using C# and VB.Net in ASP.Net<p>Hi <a class="username" rel="indradeo">indradeo</a>,</p> <p>In which format you want to change you can change in query accordingly to date format will change.</p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;asp:GridView runat=&#34;server&#34; ID=&#34;gvDate&#34; AutoGenerateColumns=&#34;false&#34;&gt; &lt;Columns&gt; &lt;asp:BoundField DataField=&#34;Date&#34; HeaderText=&#34;Date&#34; /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data; using System.Data.SqlClient; using System.Configuration; </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) { string constr = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; SqlConnection con = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(&#34;SELECT CONVERT(VARCHAR,Date,103) FROM tblDateData&#34;, con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); gvDate.DataSource = dt; gvDate.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 Dim constr As String = ConfigurationManager.ConnectionStrings(&#34;constr&#34;).ConnectionString Dim con As SqlConnection = New SqlConnection(constr) Dim cmd As SqlCommand = New SqlCommand(&#34;SELECT CONVERT(VARCHAR,Date,103) FROM tblDateData&#34;, con) Dim da As SqlDataAdapter = New SqlDataAdapter(cmd) Dim dt As DataTable = New DataTable() da.Fill(dt) gvDate.DataSource = dt gvDate.DataBind() End If End Sub</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/265271/Display-only-Date-in-GridView-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/265271/Display-only-Date-in-GridView-using-C-and-VBNet-in-ASPNet/Fri, 09 Aug 2019 06:31:13 GMT