Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
int total = 0;
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            total = System.Convert.ToInt32(e.Row.Cells[3].Text);
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[3].Text = total.ToString("c");
        }
    }

can any one say me why i am getting Input string was not in a correct format error in this coding..i know that the error was generated when converting the string value to integer.but the same line of coding is working good in another program
Posted
Updated 3-Feb-11 19:53pm
v2
Comments
Sergey Alexandrovich Kryukov 4-Feb-11 1:36am    
You're not showing input string here, only showing output. It need exception dump and the code showing lines where exception was thrown.
--SA
gowdhami 4-Feb-11 1:42am    
the error in this line
total += System.Convert.ToInt32(e.Row.Cells[3].Text);

Check the inputs you are converting. May be the value you are converting in e.Row.Cells[3].Text is not an integer value.
using int.TryParse doesn't raise any error though non integer value is passed.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 4-Feb-11 4:03am    
After OP clarified, that's the final answer - my 5.
--SA
please try e.Rows.Cells[3].value
 
Share this answer
 
Comments
gowdhami 4-Feb-11 2:42am    
sorry value is not available

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