indradeo kumar

indradeo kumar

  • 1.2k
  • 546
  • 7.6k

i want to display only date but in my code it display date a

Aug 13 2019 2:01 AM
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
  1. <%@ Page Language="C#" AutoEventWireup="true" Codefile="GeneReport.aspx.cs" Inherits="ContractCloser1.GeneReport" %>  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4. <meta name="viewport" content="width=device-width, initial-scale=1">  
  5. <style type="text/css">  
  6. .auto-style1 {  
  7. font-weightbold;  
  8. text-decorationunderline;  
  9. }  
  10. .auto-style2 {  
  11. text-decorationunderline;  
  12. }  
  13. </style>  
  14. <span class="style1">  
  15. <font color=White size=5>  
  16. <div style="margin-left:5px; width: 564px; height: 400px;"  
  17. <b><font face="Arial" size="6"><br class="auto-style2" /><br class="auto-style2" />  
  18. <span class="auto-style1">  
  19. <font color=black size=6>Generate Department LOA Details</font></span></font></font></h1>  
  20. <form id="form1" runat="server">  
  21. <span class="style1">  
  22. <font face="Arial" size="4">  
  23. <div style="margin-left: 0px; width: 566px; height: 195px;" class="auto-style1">  
  24. <div class="auto-style2">  
  25. <br />  
  26. Select Department  
  27. <asp:DropDownList ID="DropDownList1" runat="server">  
  28. </asp:DropDownList>  
  29. <br />  
  30. <br />  
  31. <asp:Button ID="Button1" runat="server" Text="GetData" OnClick="Button1_Click1" Style="height: 26px" />  
  32. <br />  
  33. <br />  
  34. </div>  
  35. <asp:GridView ID="GridView1" runat="server" BackColor="black" BorderColor="#999999"  
  36. BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" Width="561px" style="text-align: center">  
  37. <AlternatingRowStyle BackColor="" />  
  38. <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />  
  39. <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />  
  40. <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />  
  41. <RowStyle BackColor="#EEEEEE" ForeColor="Black" />  
  42. <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />  
  43. <SortedAscendingCellStyle BackColor="#F1F1F1" />  
  44. <SortedAscendingHeaderStyle BackColor="#0000A9" />  
  45. <SortedDescendingCellStyle BackColor="#CAC9C9" />  
  46. <SortedDescendingHeaderStyle BackColor="#000065" />  
  47. </asp:GridView>  
  48. </div>  
  49. </font></span></font>  
  50. </form>  
  51. </form>  
  52. </body>  
  53. </html>  
.aspx.cs
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7. using System.Data.SqlClient;  
  8. using System.Data;  
  9. namespace ContractCloser1  
  10. {  
  11. public partial class GeneReport : System.Web.UI.Page  
  12. {  
  13. string str = @"Data Source=(localdb)\Projects;Initial Catalog=Emp;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False";  
  14. protected void Page_Load(object sender, EventArgs e)  
  15. {  
  16. if (!IsPostBack)  
  17. {  
  18. BindTextBoxvalues();  
  19. }  
  20. }  
  21. private void BindTextBoxvalues()  
  22. {  
  23. SqlConnection con = new SqlConnection(str);  
  24. string com = "Select * from dept_mast";  
  25. SqlDataAdapter adpt = new SqlDataAdapter(com, con);  
  26. DataTable dt = new DataTable();  
  27. adpt.Fill(dt);  
  28. DropDownList1.DataSource = dt;  
  29. DropDownList1.DataBind();  
  30. DropDownList1.DataTextField = "dept_desc";  
  31. DropDownList1.DataValueField = "dept_code";  
  32. DropDownList1.DataBind();  
  33. }  
  34. protected void Button1_Click1(object sender, EventArgs e)  
  35. {  
  36. SqlConnection con = new SqlConnection(str);  
  37. SqlCommand cmd = new SqlCommand("select * from loa_closer where dept_code = '" + DropDownList1.SelectedValue + "'", con);  
  38. SqlDataAdapter adpt = new SqlDataAdapter(cmd);  
  39. DataTable dt = new DataTable();  
  40. adpt.Fill(dt);  
  41. GridView1.DataSource = dt;  
  42. GridView1.DataBind();  
  43. }  
  44. }  
  45. }

Answers (3)