none
Remove empty values from DataTable using Linq

    Question

  • Hi, I have a DataTable that returns me also Null and empty values from the SQL Server. How can I remove the Null and empty values with Linq and bind the result to the DropDown keeping the columns names of the DataTable?

    DataView dv = getDataTable().DefaultView;
    DataTable dtSociete = dv.ToTable(true, arrColumnsSociete);

    I tried that but it doenst recognize the fields name:
    var dtSocieteNull = dtSociete.AsEnumerable().Where(r => r.ItemArray.Any(v => v != null && v != DBNull.Value));

    Thanks

    Tuesday, November 26, 2013 10:35 AM

Answers

All replies