Note that there are some explanatory texts on larger screens.

plurals
  1. POFormatting datetime object
    primarykey
    data
    text
    <p>I have a dateTime field that i am showing in GridView. The problem is I just need to Show The date of the system And not the time but it shows both date and time. What appropriate formatting should be applied?</p> <p>this sets the date in textbox:</p> <pre><code> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TextBoxdate.Text = DateTime.Today.ToShortDateString(); } } </code></pre> <p>Retrieves from table:</p> <pre><code>public static List&lt;Workassign&gt; GetTable() { List&lt;Workassign&gt; listValues = new List&lt;Workassign&gt;(); string connectionString = "server=(local);database=project_zeshan;Integrated Security=SSPI"; SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("Select * from Assign_Work", con); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Workassign ob = new Workassign(); ob.listItem_1 =rdr["listitem_1"].ToString() ; ob.listItem_2 = rdr["listitem_2"].ToString(); ob.Description = rdr["Description"].ToString(); ob.Date= DateTime.Parse(rdr["Date"].ToString()); ob.Image = rdr["Image"].ToString(); listValues.Add(ob); } return listValues; } </code></pre> <p>And the gridView.aspx code:</p> <pre><code> &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" onselectedindexchanged="GridView1_SelectedIndexChanged"&gt; &lt;AlternatingRowStyle BackColor="White" ForeColor="#284775" /&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="listitem_1" HeaderText="ListItem1" /&gt; &lt;asp:BoundField DataField="listItem_2" HeaderText="listItem2" /&gt; &lt;asp:BoundField DataField="Description" HeaderText="Description" /&gt; &lt;asp:BoundField DataField="Date" HeaderText="Date" /&gt; &lt;asp:TemplateField HeaderText="Image"&gt; &lt;ItemTemplate&gt; &lt;asp:Image ID="Image1" runat="server" Height= "50px" Width = "100px" ImageUrl='&lt;%# Bind("Image") %&gt;' /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;EditRowStyle BackColor="#999999" /&gt; &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt; &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt; &lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt; &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt; &lt;SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /&gt; &lt;SortedAscendingCellStyle BackColor="#E9E7E2" /&gt; &lt;SortedAscendingHeaderStyle BackColor="#506C8C" /&gt; &lt;SortedDescendingCellStyle BackColor="#FFFDF8" /&gt; &lt;SortedDescendingHeaderStyle BackColor="#6F8DAE" /&gt; &lt;/asp:GridView&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload