how to select row from datagridview when column have cells is empty

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fugio
    New Member
    • Jul 2013
    • 4

    #1

    how to select row from datagridview when column have cells is empty

    Hi there !
    how to select row from datagridview when column have cells is empty
    I tried this but nothing worked
    Please help on this
    Code:
     private void selectrow()
            {
                int i;
                for( i=0 ;i<dataGridView1 .Rows .Count -1;i++)
                {
                    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();
                    }
                   
    
                }
               
            }
Working...