G
Guest
Hello,
I am using the following code to update my table through datagrid, it works
fine if I have all the field as nvarchar, if I have DateTime type filed it
raises exception by saying “String was not recognized as a valid DateTimeâ€,
how can I solve it?
protected void DataGrid1_Update(Object sender, DataGridCommandEventArgs e)
{
string debug="No Errors On Update.";
int numCols = e.Item.Cells.Count;
int key = (int)DataGrid1.DataKeys[e.Item.ItemIndex];
DataRow dr= dataSet11.tPatient.FindByPatientID(key);
NUM_LINK_COLUMNS=3;
try
{
for (int i=NUM_LINK_COLUMNS+1; i<numCols; i++)
{
string colvalue =((TextBox)e.Item.Cells.Controls[0]).Text;
dr[i-NUM_LINK_COLUMNS]= colvalue;
}
sqlDataAdapter1.Update(dataSet11);
DataGrid1.EditItemIndex = -1;
}
catch (Exception exc)
{
debug= exc.Message;
}
ResetPageIndex(DataGrid1,view);
DataGrid1.DataBind();
textBoxMessage.Text= debug;
}
Thanks,
Jim.
I am using the following code to update my table through datagrid, it works
fine if I have all the field as nvarchar, if I have DateTime type filed it
raises exception by saying “String was not recognized as a valid DateTimeâ€,
how can I solve it?
protected void DataGrid1_Update(Object sender, DataGridCommandEventArgs e)
{
string debug="No Errors On Update.";
int numCols = e.Item.Cells.Count;
int key = (int)DataGrid1.DataKeys[e.Item.ItemIndex];
DataRow dr= dataSet11.tPatient.FindByPatientID(key);
NUM_LINK_COLUMNS=3;
try
{
for (int i=NUM_LINK_COLUMNS+1; i<numCols; i++)
{
string colvalue =((TextBox)e.Item.Cells.Controls[0]).Text;
dr[i-NUM_LINK_COLUMNS]= colvalue;
}
sqlDataAdapter1.Update(dataSet11);
DataGrid1.EditItemIndex = -1;
}
catch (Exception exc)
{
debug= exc.Message;
}
ResetPageIndex(DataGrid1,view);
DataGrid1.DataBind();
textBoxMessage.Text= debug;
}
Thanks,
Jim.