datagrid column width programatically

Posted by Sudhak under ASP.NET on 10/18/2012 | Points: 10 | Views : 1894 | Status : [Member] | Replies : 2
Dear all,


How to set 2.0 Datagrid column width programatically?

below is the code

Dim sdg As New DataGrid
sdg.DataSource = losDT
sdg.DataBind()
sdg.HeaderStyle.Font.Bold = True
sdg.HeaderStyle.HorizontalAlign = HorizontalAlign.Center


Regards,
sudha




Responses

Posted by: Lalitha86 on: 10/19/2012 [Member] Starter | Points: 25

Up
0
Down
on rowdatabound

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Width = 45;

e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;


foreach (TableCell cell in e.Row.Cells)
{
cell.CssClass = "TTRow_right";
}
//e.Row.CssClass = DataBinder.Eval(e.Row.DataItem, "advsearchtmain").ToString();

}

Sudhak, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudhak on: 10/19/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks for ur reply Lalitha
but
sdg.RenderControl(htmlWrite)

i am trying to export the 2.0 datagrid to excel file

if I set the column width from the code it must affect the excel file column width


Regards,
Sudha

Sudhak, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response