Saturday, November 17, 2007

GridView Changing the row style

If you want to change the style of row or column of a gridview then it can be done in the following way

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType ==DataControlRowType.DataRow)
{
for (int i = 2; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Style.Add("text-align", "right");
//e.Row.Cells[e.Row.Cells.Count-1].Text = "" + e.Row.Cells[i].Text + "";
}
}
}

No comments: