Need to set the column width of a gridview in asp.net programatically. ** Autogenerated Columns (i.e., AutogenerateColumns = "true").
i tried the following;
protected void gv_RowCreated(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[2].Width = Unit.Pixel(200);
}
but no use.
Thanks in advance
This is my
GridView1
on aspx fileThis is where I set my GridView's column width programmatically in codebehind.It is actually about setting the cell's width but it controls the column width so this is a way.As you can see I do not have
AutogeneratedColumns="True"
, though I do not think that would matter becauseGridView.RowDataBound
occurs when a data row is bound to data.