Meinhoonaa
asked on
how to set the gridview to display only populated row
I have added logic to not to show the row. But the grid is showing empty rows. My code shown below:
e.Row.Visible = False
e.Row.Visible = False
ASKER
i need to do it at the grid level
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Put your code in the RowDataBound Control as shown below:
private void GridView_RowDataBound(Obje ct sender, GridViewRowEventArgs e) {
// Check if the first cell is empty, if it is empty then hide it.
// Note: You can change the if statement based on your needs.
if (e.Row.Cells[0].Text == "")
e.Row.Visible = false;
}
private void GridView_RowDataBound(Obje
// Check if the first cell is empty, if it is empty then hide it.
// Note: You can change the if statement based on your needs.
if (e.Row.Cells[0].Text == "")
e.Row.Visible = false;
}
ASKER
I need to remove the row in the grid. Making the row invisible is keeping extra rows in the grid.
here is linq to help you select rows which have data:-
from row in table.AsEnumerable()
where table.Columns.Cast<DataCol
select row;