By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,899 Members | 1,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,899 IT Pros & Developers. It's quick & easy.

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

fugio
P: 4
Hi there !
how to select row from datagridview when column have cells is empty
I tried this but nothing worked
Please help on this
Expand|Select|Wrap|Line Numbers
  1.  private void selectrow()
  2.         {
  3.             int i;
  4.             for( i=0 ;i<dataGridView1 .Rows .Count -1;i++)
  5.             {
  6.                 string row = dataGridView1.Rows[i].Cells["Name"].Value.ToString();
  7.                 if (row =="")
  8.                 {
  9.                     sqlconn.Open();
  10.                     string sqlquery = "select * from tbl... where id='" + dataGridView1.Rows[i].Cells["id"].Value.ToString() + "'";
  11.                     SqlCommand sqlcmd = new SqlCommand(sqlquery, sqlconn);
  12.                     SqlDataAdapter sqlda = new SqlDataAdapter(sqlcmd);
  13.                     DataTable dt = new DataTable();
  14.                     sqlda.Fill(dt);
  15.                     dataGridView1.DataSource = dt;
  16.                     sqlconn.Close();
  17.                 }
  18.  
  19.  
  20.             }
  21.  
  22.         }
Jul 21 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.