0

how can i get string empty value got filter ? as you can see when i click on empty string it wont got filter ! but when i click on null value it got filter.

filter in name

filter in number

iam using same both code on column name and number

 RepositoryItemComboBox repositoryItemComboBox1 = new RepositoryItemComboBox();
 RepositoryItemComboBox repositoryItemComboBox2 = new RepositoryItemComboBox();
 private void gridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
    {
        GridView view = sender as GridView;
        for (int i = 0; i < gridView1.RowCount; i++)
        {
        string name= gridView1.GetDataRow(i)["name"].ToString();            
        if (!repositoryItemComboBox1.Items.Contains(name))
           {
           repositoryItemComboBox1.Items.Add(name);
           }
        string number= gridView1.GetDataRow(i)["number"].ToString();            
        if (!repositoryItemComboBox2.Items.Contains(number))
           {
           repositoryItemComboBox2.Items.Add(number);
           }
        }
    }

in database name got empty value and number got null value. is there a problem with my code? how should i modify the code? edited iam adding this piece of code it gives me no where , still cant get it filter

 if (string.IsNullOrEmpty(name))
            {
                string xa = "";
                if (!repositoryItemComboBox11.Items.Contains(xa))
                {
                    repositoryItemComboBox11.Items.Add(xa);
                }
            }
chopperfield
  • 559
  • 1
  • 7
  • 25

1 Answers1

0
name= gridView1.GetDataRow(i)["name"].ToString(); 

You should not use ToString method directly. Because if the value is null, this will cause an exception.

Huy Nguyen
  • 2,025
  • 3
  • 25
  • 37