Click here to Skip to main content
15,885,126 members
Please Sign up or sign in to vote.
2.60/5 (2 votes)
See more:
I have the following code:

C#
bool comparedResults = true;
            TextBox txtAddFROMKMREAD = (TextBox)GRDTech.FooterRow.FindControl("txtAddFROMKMREAD");
            DropDownList drpPlateNum = (DropDownList)Default._def.GRDTech.FooterRow.FindControl("drpPlateNum");
            int readDepartureKM = Convert.ToInt32(txtAddFROMKMREAD.Text);

            TextBox txtAddTOKMREADING = (TextBox)Default._def.GRDTech.FooterRow.FindControl("txtAddTOKMREADING");

            int arrivalKMreading = Convert.ToInt32(txtAddTOKMREADING.Text);


            comparedResults = (arrivalKMreading < readDepartureKM);


C#
int readDepartureKM = Convert.ToInt32(txtAddFROMKMREAD.Text);


keeps on giving me invalid string input.
the error is raised when I click on the update button, but when I insert it to the database it works perfectly...

MORE DETAILED ERRORS

SQL
when converting a string to DateTime, parse the string to take the date before putting each variable into the DateTime object

Make sure your method arguments are in the right format


my Datatype in my server is INT

I have no idea why the error is DatTime?

any help please
Posted
Comments
Laiju k 24-Apr-14 0:07am    
what is txtAddFROMKMREAD.Text entry value

where is the update button code of database insertion.are you using stored procedures
ArunRajendra 24-Apr-14 0:39am    
Put the break point and see what is the value in txtAddFROMKMREAD.Text
JB0301 24-Apr-14 0:39am    
the value is 0

1 solution

your code and check right control u find
C#
DropDownList drpPlateNum = (DropDownList)Default._def.GRDTech.FooterRow.FindControl("drpPlateNum");
          int readDepartureKM = Convert.ToInt32(txtAddFROMKMREAD.Text);

          TextBox txtAddTOKMREADING = (TextBox)Default._def.GRDTech.FooterRow.FindControl("txtAddTOKMREADING");

To
XML
<pre lang="c#">
 DropDownList drpPlateNum = (DropDownList)GRDTech.FooterRow.FindControl("drpPlateNum");
            int readDepartureKM = Convert.ToInt32(txtAddFROMKMREAD.Text);
 
            TextBox txtAddTOKMREADING = (TextBox)GRDTech.FooterRow.FindControl("txtAddTOKMREADING");
</pre>
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900