Click here to Skip to main content
15,936,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the following code I am unable to assign the value at cell[1] to a variable v_orderno. I get error like 'bool does not have a definition for cells..'.
C#
protected void dataGridView1_CellClick (object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv = sender as DataGridView;
            if (dgv.CurrentRow.Selected)
            {
                v_orderno = (dgv.CurrentRow.Selected.Cells[1].Text);
            }
Posted
Comments
[no name] 30-Mar-14 5:29am    
Where/how is v_orderno defined?
S.Rajendran from Coimbatore 30-Mar-14 5:34am    
v_orderno is a static int variable.

1.Your error is generated because you are using a wrong property that has type bool: dgv.CurrentRow.Selected

2.You should access your row cells by using: dw.CurrentRow.Cells[1]
or better by using directly: dw.CurrentCell
 
Share this answer
 
hi, try this...
C#
protected void dataGridView1_CellClick (object sender, DataGridViewCellEventArgs e)
{
     int orderno = 0;
     Int32.TryParse(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(), out orderno);
     v_orderno = orderno;
}

Happy Coding!
:)
 
Share this answer
 

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