2012-10-25 119 views
1

在我的DataTable的列中有空值。當我在此表上創建一個DataView時,我想篩選出空值。我該怎麼做呢?排除DataView中的空值

我得到了我的代碼如下工作:

//get the cities and a view on the data 
DataTable dtPlaatsen = client.getCities(); 
DataView dvPlaatsen = dtPlaatsen.DefaultView; 

// filter and sort the view 
dvPlaatsen.RowFilter= "Isnull(Plaatsnaam,'Null Column') <> 'Null Column'"; 
dvPlaatsen.Sort = "Plaatsnaam"; 


//attach the view as datasource 
ddlCities.DataSource = dvPlaatsen; 
ddlCities.DataTextField = "Plaatsnaam"; //the field to display to the user 
ddlCities.DataValueField = "PlaatsId"; //the field which is send 

ddlCities.DataBind(); 

ddlCities.SelectedIndex = 50; 
+0

使用您的數據視圖的RowFilter – dansasu11

回答

0

請嘗試以下

Isnull(Plaatsnaam, 'Null Column') != 'Null Column' 

我剛剛從相關線程here修改的接受的答案。當然,如果它有效,你應該感謝Michael Kjörling的幫助。

1

嘗試這樣排序之前,但無論過濾器,你想做的事,使用數據視圖行篩選

  dvPlaatsen.RowFilter = "Plaatsnaam <> null"