Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to hide gridview if date of leaving is exit in row of specific employee.

What I have tried:

if (e.Row.RowType == DataControlRowType.DataRow)

{

string rowValue = e.Row.Cells[4].Text;
if (string.IsNullOrEmpty(rowValue))
{
e.Row.Cells[4].Visible = false;
}
Posted
Updated 21-Dec-18 23:32pm
Comments
OriginalGriff 22-Dec-18 5:09am    
And where did you put that code?
akhter86 22-Dec-18 5:16am    
here
protected void GVEmpDetails_RowDataBound(object sender, GridViewRowEventArgs e)
akhter86 22-Dec-18 5:18am    
i want if employee date of leaving is exit then that employee does not come in row of gridview

1 solution

If I understand your question correctly, I would't try to hide individual rows from the gridview. Instead I wouldn't include the row in the data items in the first place.

For example if the data is coming from a datatable, you could use DataTable.Select Method (System.Data) | Microsoft Docs[^] to filter out the rows you don't want to show. If the data is coming from a database, perhaps it would make sense to filter them out already when querying the table.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900