Click here to Skip to main content
15,882,152 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I >am trying to approve documents in when admin login then they approve documents 2 or 3 days ago code works fine now when i again open my project and approve documents it shows me error "Input string was in correct format "

here is the button code.

protected void Button1_Click(object sender, EventArgs e)

        string connStr = 
        SqlConnection mySQLconnection = new SqlConnection(connStr);

        for (int i = 0; i < Repeater2.Items.Count; i++)
            DropDownList DropDownListcontrol =
            Label DocId = ((Label)Repeater2.Items[i].FindControl("DocId"));
             SqlCommand cmd = new SqlCommand("approveddd", mySQLconnection);
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add("@DocID", SqlDbType.Int).Value = 

                cmd.Parameters.Add("@ApproveID", SqlDbType.Int).Value = 
                cmd.Parameters.Add("@ApproveBy", SqlDbType.VarChar, 50).Value =


                DMSLIB.Doc myDoc = new DMSLIB.Doc();

           catch (Exception ex)
                apfi.Text = "Error";

please any one tell me where is the problem occur... ??

1 solution

"Input string was in correct format" error came from Convert.ToInt32.
It means, that the value you just passed can not be converted to int.
To see where exactly the error occurs, remove the try-catch-finally block and run again.
Share this answer
Diya Ayesa 13-Nov-13 9:15am    
so what i write instead of try catch
Kornfeld Eliyahu Peter 13-Nov-13 9:19am    
Nothing. It's not the source of the error. Removing it will help you find out which of the two Convert.ToInt32 causes the error, and in turn it will tell you the source of the error...
Diya Ayesa 13-Nov-13 9:24am    
removing try catch may be bracket error comes in this...//catch (Exception ex)
apfi.Text = ex.Message;
Kornfeld Eliyahu Peter 13-Nov-13 10:05am    
Of course, you have no ex... Comment this line out too...
Kornfeld Eliyahu Peter 14-Nov-13 6:27am    
It's because you didn't commented out finally - it's part of the try complex...

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

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