J
J055
Hi
I've been looking into different ways of formatting columns/rows in the
GridView control. I realize now, I think, that once the datasource is bound
to the control the original column type information is lost, i.e. converted
to a string.
So my question is: is it better to format data while it's still in a
DataTable, for example, then bind it to the control, or format the strings
in the BoundField elements, or if more flexibility is needed, in the
RowDataBound event?
If I do the later then I end up doing things like this:
cell = (DataControlFieldCell)(e.Row.Controls[MYDATE_COLUMN])
cell.Text = cell.Text.Substring(0, 16)
Or converting the string to a date and then formatting the date back to a
string.
I'm sure there are better ways so I'm just wondering if anyone has some good
experience with these kinds of issues?
Thanks
Andrew
I've been looking into different ways of formatting columns/rows in the
GridView control. I realize now, I think, that once the datasource is bound
to the control the original column type information is lost, i.e. converted
to a string.
So my question is: is it better to format data while it's still in a
DataTable, for example, then bind it to the control, or format the strings
in the BoundField elements, or if more flexibility is needed, in the
RowDataBound event?
If I do the later then I end up doing things like this:
cell = (DataControlFieldCell)(e.Row.Controls[MYDATE_COLUMN])
cell.Text = cell.Text.Substring(0, 16)
Or converting the string to a date and then formatting the date back to a
string.
I'm sure there are better ways so I'm just wondering if anyone has some good
experience with these kinds of issues?
Thanks
Andrew