flexible textbox widths in a datagrid

T

TB

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
 
G

Guest

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
 
T

TB

Thanks a lot for a very complete answer (with source code and all).
Very instructive.

TB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top