M
mohaaron
OK, I have now gone through lots of posts, and there are lots, looking
for a anwer as to why I can't set the width of the columns in my
gridview. So far I have tried the following methods to set the width
and nothing works.
1. <asp:BoundField HeaderText="fieldName" ItemStyle-Width="300px"
DataField="fieldName" />
2. <asp:BoundField HeaderText="fieldName" HeaderStyle-Width="300px"
DataField="fieldName" />
3. This has been tried in both the RowCreated and RowDataBound events.
foreach (TableCell cell in e.Row.Cells)
{
int width = cell.Text.Length * 10;
cell.Width = Unit.Pixel(width);
}
4. This has been tried in both the RowCreated and RowDataBound events.
foreach (DataControlField field in this.searchGrid.Columns)
{
field.ItemStyle.Width = Unit.Pixel(500);
}
Why is it so diffecult to do something that should be so simple?
for a anwer as to why I can't set the width of the columns in my
gridview. So far I have tried the following methods to set the width
and nothing works.
1. <asp:BoundField HeaderText="fieldName" ItemStyle-Width="300px"
DataField="fieldName" />
2. <asp:BoundField HeaderText="fieldName" HeaderStyle-Width="300px"
DataField="fieldName" />
3. This has been tried in both the RowCreated and RowDataBound events.
foreach (TableCell cell in e.Row.Cells)
{
int width = cell.Text.Length * 10;
cell.Width = Unit.Pixel(width);
}
4. This has been tried in both the RowCreated and RowDataBound events.
foreach (DataControlField field in this.searchGrid.Columns)
{
field.ItemStyle.Width = Unit.Pixel(500);
}
Why is it so diffecult to do something that should be so simple?