Hi All:
I have this datagrid where space is very tight, and therefore I have to
make sure that everything fits within a fixed screen width regardless
of whether I am in list mode or in edit mode. But I have discovered
that it is not enough to simply specify the column widths by way of
'HeaderStyle-Width="25px" ItemStyle-Width="25px"'-type properties
inside in the <asp:BoundColumn> tags, because by default all the text
boxes in edit mode have the same length, greatly expanding the total
width of the datagrid each time I press the edit button.
So then I thought I could use the following style sheet entry (kindly
provided by somebody else in this forum but for another purpose):
.MyListItem td input
{
font-family: Verdana;
font-size:9px;
width:25px;
}
and the call it from datagrid: <EditItemStyle
CssClass="MyListitem"></EditItemStyle>
But of course the problem is then that while this entry does control
the text box width, it is common for ALL the columns, rendering it
useless, because I need each of the textboxes to have the same width as
their corresponding column widths expressed in the <asp:BoundColumn
DataField="Fieldname" HeaderText="Fieldname" HeaderStyle-Width="25px"
ItemStyle-Width="25px"></asp:BoundColumn> tags.
Any suggestions will be highly appreciated.
Thanks,
TB
Phillip Williams - 14 Oct 2005 11:58 GMT
Cascading style sheets can help you define a general style for the entire
datagrid (which you discovered below) but also to specify individual columns'
styles by specifying a cssClass for each DataBoundColumn by setting
properties such as HeaderStyle-cssClass and ItemStyle-CssClass.
This is an example where the textbox size, the background-color and the font
is different for each column that overrides the default cssClass settings for
the datagrid http://www.societopia.net/samples/DataGrid_cssClass.aspx

Signature
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
> Hi All:
>
[quoted text clipped - 32 lines]
>
> TB
TB - 15 Oct 2005 19:10 GMT
Thanks a lot for a very complete answer (with source code and all).
Very instructive.
TB