Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date displays as DateTime
Message
De
21/12/2009 19:47:10
 
 
À
21/12/2009 19:00:36
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01439892
Message ID:
01440104
Vues:
48
My guess would be just intellisense your way to the property.

I just tried it and got

dgvMyGrid.Columns.Item(1).CellTemplate.Style.Format = "d"
or
dgvMyGrid.Columns.Item("MydateColumn").CellTemplate.Style.Format = "d"

( I have to admit it wasn't immediately apparent <s> )

Of course I haven't done any webforms yet and I'm just assuming the control works the same way there, but give it a try and let me know

oh, and there is a cellformatting event for the dgv, so you may have to handle that and set it there if you are doing it programmatically.

But is this necessary on a web form? Can't you set the property on the grid control itself at design time?




>Hi Charles. Thanks for taking the time to respond. I'm not sure your suggestion works for me because I'm doing everything in the VB Code-behind rather than on the Properties sheet.
>
>Do you have any suggestions/samples for how to apply the formatting to a particular column in code?
>
>Thanks............Rich
>
>
>>In the datagridview, take a look at the columns collection. On that column find the defaultcellstyle (top of list) hit the elipsis on the end of the line and in the Format property hit the elipsis again ( or just put a small d in the Format property )
>>
>>
>>>I have a GridView control on a form. There is a button which populates the grid
>>>Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
>>>
>>>        Dim tvPage1 As TreeView = CType(Session("treeview"), TreeView)
>>>
>>>        Dim strConn As String = CType(Me.Master, MasterPage).connectString
>>>        Dim objConn As New MySqlConnection(strConn)
>>>        Dim objDS As New DataSet
>>>
>>>        Dim ldDate As String = (CType(ddlDates.SelectedValue, Date).GetDateTimeFormats())(66)
>>>
>>>        Dim strSql As String
>>>        strSql = "SELECT action,totNumberActions,Status,totCountStatus,categoryname,createdate " & _
>>>                 "  FROM kpi_mrpactions " & _
>>>                 " WHERE savedate = '" & ldDate & "'" & _
>>>                 "  ORDER BY action,status "
>>>
>>>        Dim daMrp As New MySqlDataAdapter(strSql, objConn)
>>>        daMrp.Fill(objDS, "dtMrp")
>>>        GridView1.DataSource = objDS
>>>        GridView1.DataBind()
>>>
>>>End Sub
>>>
>>>The data is coming from a MySql table.
>>>The < createdate > column is of type DATE (definitely not DATETIME -- I checked). But the column in the gridview is showing a Time portion (for example: 12/12/2009 12:00:00 AM).
>>>
>>>Is there a setting somewhere that maps Dates to DateTime displays????
>>>
>>>Is there some way to modify the display so that only the date portion shows???
>>>
>>>Is there some way to modify the query to ensure a date value is returned and displayed as a date???
>>>
>>>All replies greatly appreciated............Rich


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform