G
Guest
All,
I would be very grateful for any help on this question. I have an
application in asp.net 2.0 where I dynamically create a datatable and then
bind that to a gridview. Unfortunately, the date column always shows the
date and time while I just want the short date. I have tried applying a
format string {0:d} but to no avail. I saw a lot of posts regarding the
htmlencode property but I do not know how to turn that off for a dynamically
created column - can it be done? If so, that may solve my problem. Here is
a small snapshot of what I am doing:
Dim dcLeaveDate As New DataColumn("LeaveDate", GetType(Date))
Dim dtleaveformdays As New DataTable
dtleaveformdays.Columns.Add(dcLeaveDate)
gvDays.DataSource = dtleaveformdays
gvDays.DataBind()
gvDays is my gridview and I cannot get the date column to format. I even
tried doing this in the rowcreated function:
Protected Sub gvDays_RowCreated........
e.Row.Cells(0).Text = String.Format("{0:d}", e.Row.Cells(0).Text)
Please help - I need to do this dynamically and keep track of all changes
they make before they actually submit the data. At that point, I will save
the datatable to a sql table. In the meantime, dynamic formatting is giving
me a headache (-:
Thanks,
Ken
I would be very grateful for any help on this question. I have an
application in asp.net 2.0 where I dynamically create a datatable and then
bind that to a gridview. Unfortunately, the date column always shows the
date and time while I just want the short date. I have tried applying a
format string {0:d} but to no avail. I saw a lot of posts regarding the
htmlencode property but I do not know how to turn that off for a dynamically
created column - can it be done? If so, that may solve my problem. Here is
a small snapshot of what I am doing:
Dim dcLeaveDate As New DataColumn("LeaveDate", GetType(Date))
Dim dtleaveformdays As New DataTable
dtleaveformdays.Columns.Add(dcLeaveDate)
gvDays.DataSource = dtleaveformdays
gvDays.DataBind()
gvDays is my gridview and I cannot get the date column to format. I even
tried doing this in the rowcreated function:
Protected Sub gvDays_RowCreated........
e.Row.Cells(0).Text = String.Format("{0:d}", e.Row.Cells(0).Text)
Please help - I need to do this dynamically and keep track of all changes
they make before they actually submit the data. At that point, I will save
the datatable to a sql table. In the meantime, dynamic formatting is giving
me a headache (-:
Thanks,
Ken