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
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#:
[COLOR=#000000]void filter()[/COLOR] {
try
{
if (dataGridView1.Rows.Count > 0 )
{
for (int i =0 ; i<=dataGridView1.Rows.Count ;i++)
{
for (int j=0; j<=dataGridView1 .Rows .Count ;j++)
{
string row = dataGridView1.Rows[i].Cells["UserName"].Value.ToString().Trim();
if (row =="")
{
dataGridView1.Rows.RemoveAt(i);
i--;
//sqlconn.Open();
//string sqlquery = "select * from tbl... where id='" + dataGridView1.Rows[i].Cells["UserID"].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();
}
}
}
}
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}
[COLOR=#000000] }[/COLOR]