How to bind only data which have value?
By James J
Bind that data which has not null or empty value...
private void CheckboxListBind()
{
SqlConnection conn = new SqlConnection("connection string");
conn.Open();
SqlDataReader dr;
SqlCommand cmd = new SqlCommand("SELECT ename FROM employee", conn);
dr = cmd.ExecuteReader();
while (dr.Read())
{
if(dr.GetValue(0).ToString()!=string.Empty.Trim())
{
checkedListBox1.Items.Add(dr.GetValue(0).ToString());
}
}
conn.Close();
}
How to bind only data which have value? (594 Views)