Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting DataGrid

Status
Not open for further replies.

quinnipiac0807

Programmer
Oct 25, 2004
38
US
I'm just trying to convert a column in a datagrid to dd-mm-yyyy instead of day/month/year and then time.

This is my statement:

try
{
DateTime StartTime = Convert.ToDateTime(drv.Row.ItemArray[1]);
e.Item.Cells[1].Text = StartTime.ToShortDateString();
}
catch
{
e.Item.Cells[1].Text = "";
}

For some reason it skips over the try after it executes the first line (DateTime StartTime ....) and goes right to the catch, printing nothing. There is data there that should be converted. StartTime is in Column 1 so that's not the problem but I don't understand why it skips to the catch.
 
print out the error that occurs instead of catching it for testing purposes..you may learn more as to why it's erroring out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top