Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET4.0
Hi.
I have a gridView and i have written it's Edit & Update statement with my own ,but the problem i have i can't convert two of gridview textbox which are assigned to BirthDate(datatype=date)and average(datatype=decimal) , and now when i debugg the solution this message is appeared:
 
The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.
and somethig the same message for average.
 
my code i have written is as below:
protected void Grid_Updating(object sender, GridViewUpdateEventArgs e) 
    { 
        SqlCommand cmd = DataProvider.GenerateCommand("Update_HowzeEducation_SP", CommandType.StoredProcedure); 
        cmd.Connection.Open(); 
 
        cmd.Parameters.Add("@FieldName", SqlDbType.NVarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text; 
        cmd.Parameters.Add("@FinishLevelDate", SqlDbType.Date).Value = Convert.ToDateTime(((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text.Trim()); 
        cmd.Parameters.Add("@Average", SqlDbType.Decimal).Value = decimal.parse(((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text); 
        cmd.Parameters.Add("@SchoolName", SqlDbType.NVarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text; 
        cmd.Parameters.Add("@StudyCityDescribtion", SqlDbType.NVarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[5].Controls[0]).Text; 
        cmd.Parameters.Add("@ThesisTitle", SqlDbType.NVarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[6].Controls[0]).Text; 
        cmd.Parameters.Add("@Describtion", SqlDbType.NVarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[7].Controls[0]).Text; 
        cmd.Parameters.Add("@HowzeEducationId", SqlDbType.Int).Value = GlobalVariables.HowzeEducationId; 
 
        cmd.ExecuteScalar(); 
 
    } 
Posted 8-Oct-12 23:19pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 451
1 Afzaal Ahmad Zeeshan 184
2 /\jmot 176
3 Marcin Kozub 150
4 Sergey Alexandrovich Kryukov 150
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 9 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100