The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.

Posted by Sudheep.grandhe under C# on 1/11/2012 | Points: 10 | Views : 14145 | Status : [Member] | Replies : 5
Hi,

i wrote the code for gridview_cellcontentdoubleclick.but it shows the following error.

private void dataSimpeGrid_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (dataSimpeGrid.SelectedRows.Count > 0)
{
cmbparticulars.Text = dataSimpeGrid.SelectedRows[0].Cells[0].Value.ToString();
txtquantity.Text = dataSimpeGrid.SelectedRows[0].Cells[1].Value.ToString();
txtperprice.Text = dataSimpeGrid.SelectedRows[0].Cells[2].Value.ToString();
txtamount.Text = dataSimpeGrid.SelectedRows[0].Cells[3].Value.ToString();
cmbcompanyname.Text = dataSimpeGrid.SelectedRows[0].Cells[4].Value.ToString();
txtinvoicedate.Text = dataSimpeGrid.SelectedRows[0].Cells[5].Value.ToString();//error comes here
txtondate.Text = dataSimpeGrid.SelectedRows[0].Cells[6].Value.ToString();
txtorderno.Text = dataSimpeGrid.SelectedRows[0].Cells[7].Value.ToString();
}
}

Best,
Sudheep.



Responses

Posted by: perfectchourasia-9163 on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
convert the date to datetime format.

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

how can i convert can you reply

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
string date= txtPckgStartDate.Value.Trim();

date = Convert.ToDateTime(date);

When you are retrivinging value on that time convert to datetime .

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

error comes here .can you correct these two lines

txtinvoicedate.Text = dataSimpeGrid.SelectedRows[0].Cells[5].Value.ToString();//error comes here
txtondate.Text = dataSimpeGrid.SelectedRows[0].Cells[6].Value.ToString();

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ogipansrk on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down

post your error, with inner exception message.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response