Hide specific Row from ASP.Net GridView based on condition using C#

Last Reply 6 months ago By AbdulHaque

Posted 6 months ago

i want to hide row from gridview if specifice row cell value exit ,mean

if employee date of leave is exit then specific employee not show in gridview 

i tried this but not getting result

        protected void GVEmpDetails_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //Where index of cells is the column position in the Grid
                //just changed it based on your requirements
                string rowValue = e.Row.Cells[4].Text;
                if (string.IsNullOrEmpty(rowValue))
                {
                    e.Row.Cells[4].Visible = false;
                }

 

Posted 6 months ago Modified on 6 months ago

Hi @Akther

Try the below code.

protected void GVEmpDetails_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.Cells[4].Text == "Exit")
        e.Row.Visible = false;
}