i want to display only date but in my code it display date and time both how to do this.
i want to display "01-01-1900" only but same are display
"01-01-1900 00:00:00" how to remove time.
.aspx
- <%@ Page Language="C#" AutoEventWireup="true" Codefile="GeneReport.aspx.cs" Inherits="ContractCloser1.GeneReport" %>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <style type="text/css">
- .auto-style1 {
- font-weight: bold;
- text-decoration: underline;
- }
- .auto-style2 {
- text-decoration: underline;
- }
- </style>
- <span class="style1">
- <font color=White size=5>
- <div style="margin-left:5px; width: 564px; height: 400px;"
- <b><font face="Arial" size="6"><br class="auto-style2" /><br class="auto-style2" />
- <span class="auto-style1">
- <font color=black size=6>Generate Department LOA Details</font></span></font></font></h1>
- <form id="form1" runat="server">
- <span class="style1">
- <font face="Arial" size="4">
- <div style="margin-left: 0px; width: 566px; height: 195px;" class="auto-style1">
- <div class="auto-style2">
- <br />
- Select Department
- <asp:DropDownList ID="DropDownList1" runat="server">
- </asp:DropDownList>
- <br />
- <br />
- <asp:Button ID="Button1" runat="server" Text="GetData" OnClick="Button1_Click1" Style="height: 26px" />
- <br />
- <br />
- </div>
- <asp:GridView ID="GridView1" runat="server" BackColor="black" BorderColor="#999999"
- BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" Width="561px" style="text-align: center">
- <AlternatingRowStyle BackColor="" />
- <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
- <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
- <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
- <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
- <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
- <SortedAscendingCellStyle BackColor="#F1F1F1" />
- <SortedAscendingHeaderStyle BackColor="#0000A9" />
- <SortedDescendingCellStyle BackColor="#CAC9C9" />
- <SortedDescendingHeaderStyle BackColor="#000065" />
- </asp:GridView>
- </div>
- </font></span></font>
- </form>
- </form>
- </body>
- </html>
.aspx.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.SqlClient;
- using System.Data;
- namespace ContractCloser1
- {
- public partial class GeneReport : System.Web.UI.Page
- {
- string str = @"Data Source=(localdb)\Projects;Initial Catalog=Emp;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False";
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- BindTextBoxvalues();
- }
- }
- private void BindTextBoxvalues()
- {
- SqlConnection con = new SqlConnection(str);
- string com = "Select * from dept_mast";
- SqlDataAdapter adpt = new SqlDataAdapter(com, con);
- DataTable dt = new DataTable();
- adpt.Fill(dt);
- DropDownList1.DataSource = dt;
- DropDownList1.DataBind();
- DropDownList1.DataTextField = "dept_desc";
- DropDownList1.DataValueField = "dept_code";
- DropDownList1.DataBind();
- }
- protected void Button1_Click1(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(str);
- SqlCommand cmd = new SqlCommand("select * from loa_closer where dept_code = '" + DropDownList1.SelectedValue + "'", con);
- SqlDataAdapter adpt = new SqlDataAdapter(cmd);
- DataTable dt = new DataTable();
- adpt.Fill(dt);
- GridView1.DataSource = dt;
- GridView1.DataBind();
- }
- }
- }