Apply Margin to GridView Cell inside RowDataBound event using CSS in ASP.Net

Last Reply on Dec 11, 2017 06:01 AM By mukesh1

Posted on Dec 11, 2017 05:35 AM


I want to add Top margin to my Cells in GridView inside the RowDataBound event, please help.

protected void grdperformance_RowDataBound(object sender, GridViewRowEventArgs e)
    if (e.Row.RowType == DataControlRowType.DataRow)
        // Display the company name in italics.
        //e.Row.Cells[1].Text = "<i>" + e.Row.Cells[1].Text + "</i>";
        e.Row.Cells[3].ForeColor = Color.Red;

        e.Row.Cells[12].CssClass = "label label-info pull-left";
Posted on Dec 11, 2017 06:01 AM

 I finally managed to do it.

 e.Row.Cells[12].Style.Add("margin-top", "2px");
 e.Row.Cells[12].Style.Add("margin-bottom", "2px");