Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

flexible textbox widths in a datagrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TB - 14 Oct 2005 00:58 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.