error message fix

Posted by user1722654 on Stack Overflow See other posts from Stack Overflow or by user1722654
Published on 2012-10-08T15:33:19Z Indexed on 2012/10/08 15:37 UTC
Read the original article Hit count: 143

Filed under:
|
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
    //bool sleected = false;

    if (dataGridView1.Rows[i].Cells[3].Value != null)
    {

        selected.Add(i);
    }

}
//string donew = "";


// line off error 
textBox1.Text = ((String)dataGridView1.Rows[1].Cells[2].Value);
/*  for (int i = 0; i < selected.Count; i++)
{

    textAdded.Add((String)dataGridView1.Rows[0].Cells[2].Value);
 //   donew += (String)dataGridView1.Rows[selected[i]].Cells[2].Value;
}*/

I keep getting the error

Unable to cast object of type 'System.Double' to type 'System.String'

What can I do to overcome this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about datagridview