Hi,
I am got this datetime value into datagrid cell with {0:dd/MM/yyyy} as data formatting expression. Displayed at datagrid's fine ie. 14/07/2006 but after I edited it to 14/07/2007 and try to save, it will prompt this msg.
Cast from string "14/07/2006" to type 'Date' is not valid.
I've tried to update with this format #14/7/2006# too but still failed.
Below are my codes, pls help to see where when wrong.
Thanks!
Dim vCdate As String, tb As TextBox
Dim key As String = DataGrid1.DataKeys(e.Item.ItemIndex).ToString()
tb = CType(e.Item.Cells(2).Controls(0), TextBox)
vCdate = tb.Text
Dim r As DSComplaint.tblComplaintRow
r = DsComplaintEdit1.tblComplaint.FindByComplaintNo(key)
r.CompDate = vCdate
SqlDataAdapter1.Update(DsComplaintEdit1)
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
I am got this datetime value into datagrid cell with {0:dd/MM/yyyy} as data formatting expression. Displayed at datagrid's fine ie. 14/07/2006 but after I edited it to 14/07/2007 and try to save, it will prompt this msg.
Cast from string "14/07/2006" to type 'Date' is not valid.
I've tried to update with this format #14/7/2006# too but still failed.
Below are my codes, pls help to see where when wrong.
Thanks!
Dim vCdate As String, tb As TextBox
Dim key As String = DataGrid1.DataKeys(e.Item.ItemIndex).ToString()
tb = CType(e.Item.Cells(2).Controls(0), TextBox)
vCdate = tb.Text
Dim r As DSComplaint.tblComplaintRow
r = DsComplaintEdit1.tblComplaint.FindByComplaintNo(key)
r.CompDate = vCdate
SqlDataAdapter1.Update(DsComplaintEdit1)
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()