Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there !
how to select row from datagridview when column have cells is empty
I tried couple of this but nothing worked
Please help on this
C#
private void selectrow()
       {
           int i;
           for( i=0 ;i<datagridview1 .rows="" .count="" mode="hold" />            {
               string row = dataGridView1.Rows[i].Cells["Name"].Value.ToString();
               if (row =="")
               {
                   sqlconn.Open();
                   string sqlquery = "select * from tbl... where id='" + dataGridView1.Rows[i].Cells["id"].Value.ToString() + "'";
                   SqlCommand sqlcmd = new SqlCommand(sqlquery, sqlconn);
                   SqlDataAdapter sqlda = new SqlDataAdapter(sqlcmd);
                   DataTable dt = new DataTable();
                   sqlda.Fill(dt);
                   dataGridView1.DataSource = dt;
                   sqlconn.Close();
               }
           }
       }
Posted
Updated 21-Jul-13 0:59am
v2
Comments
Basmeh Awad 21-Jul-13 9:22am    
"how to select row from datagridview when column have cells is empty"
what you need in row??
not clear??
Manikandan Sekar 22-Jul-13 2:55am    
Tell your need clearly

1 solution

Don't check for empty rows in loop. Perhaps, get all the datarows. Then use if condition to check row value. If its empty, get the datarow cell name and go ahead and do your thing.
 
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