Hi,
I have a gridview with the column displaying date value. But in DB its datetime datatype.
Label date = (Label)GridView1.Rows[e.RowIndex].FindControl("Date");
In my screen the date value displays like `2014-05-3O` in the grid and in database the value is like `2014-05-30 00:00:00.000`, where I converted datetime to date to show it in the screen. Now I m trying to delete the row and it gives an error. The problem is how can I convert this date to datetime, so that I can pass the string in the delete statement.
Anyone help me with this?
Loading
Khan Abrar AhmedPosted Jun 10, 2014, 9:01 AM
Label date = (Label)GridView1.Rows[e.RowIndex].FindControl("Date");
string strdate = Convert.ToDateTime(date.Text).ToString("dd/MMM/yyyy");
Khan Abrar AhmedPosted Jun 10, 2014, 10:06 AM
1016, 1023T
Vignesh KumarPosted Jun 10, 2014, 9:29 AM
That worked.
I have another column where the datatype is varchar and it has values like 1016, 1023T and when I try to delete I get the error.
Label ID = (Label)GridView1.Rows[e.RowIndex].FindControl("lblID");
Error converting data type varchar to numeric.