Tuesday, 20 May 2014

GridView remove all cells but one(footer)

if (e.Row.RowType == DataControlRowType.Footer)
            {
                //remove all cells but one, so GridView1.Columns.Count-1
                for (int i = 0; i < grvLeaveDetail.Columns.Count - 1; i++)
                    e.Row.Cells.RemoveAt(0);

                e.Row.Cells[0].ColumnSpan = grvLeaveDetail.Columns.Count;
                e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Left;

                if (ViewStateLeaveDetail.Count == 0)
                    e.Row.Cells[0].Text = "You have to apply at least one leave";
                else
                    e.Row.Cells[0].Text = "You have applied " + DaysCount + " leave";
            }

No comments:

Post a Comment