473,614 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

flexible textbox widths in a datagrid

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:BoundColum n> 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: <EditItemStyl e
CssClass="MyLis titem"></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:BoundColum n
DataField="Fiel dname" HeaderText="Fie ldname" HeaderStyle-Width="25px"
ItemStyle-Width="25px"></asp:BoundColumn > tags.

Any suggestions will be highly appreciated.

Thanks,

TB

Nov 19 '05 #1
2 2046
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/Da..._cssClass.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"TB" wrote:
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:BoundColum n> 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: <EditItemStyl e
CssClass="MyLis titem"></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:BoundColum n
DataField="Fiel dname" HeaderText="Fie ldname" HeaderStyle-Width="25px"
ItemStyle-Width="25px"></asp:BoundColumn > tags.

Any suggestions will be highly appreciated.

Thanks,

TB

Nov 19 '05 #2
TB
Thanks a lot for a very complete answer (with source code and all).
Very instructive.

TB

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2336
by: TB | last post by:
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...
3
9458
by: Ronald S. Cook | last post by:
Hi all, I have an ASP.NET DataGrid wherein there is an edit link for each row. Upon clicking the link, certan fields in that row display in text boxes so that they may be edited. I would like some textboxes to be wider, some narrower. By default, they are all the same pre-defined width. Does anyone know how I can do this? Thanks very much,
3
3817
by: sck10 | last post by:
Hello, I am using a datagrid and am trying to control the column widths for each column. Is this possible? I have tried using the following: ControlStyle-BorderWidth="1000" with no apparent results. temStyle-BorderWidth="200" with my column turning black. ControlStyle-Width="200" with no apparent results. Any help would be appreciated.
6
7093
by: cr113 | last post by:
I'm trying to set the column widths for a datagrid. You'd think it would be easy. I looked it up in google and the first thing I found looked promising: datagrid1.columns(0).width = 2000 datagrid1.columns(1).width = 1000 Except that there is no such things as a columns collection in a datagrid.
1
2275
by: kpg | last post by:
Hi All, me again. I've got my web form data grid set up pretty nice. But how do you set the column width? The columns seem to grow and shrink based on the width of the data in them (that's ok) but if the data gets to long I get word wrap in the cell and the whole datagrid grows past the end of my page. I want to set fixed column width and prevent word wrap.
4
4188
by: Rich | last post by:
Hello, I have a one datagrid that will be based on different datatables. One datatable may have 7 columns, another 15... With the tables that have more columns, I have been manually dragging column widths to narrow them. I want to record these widths so I can reapply them when I bind the datagrid to the table with 15 columns. I have searched around for articles on this and saw some that talked about...
2
3377
by: Calvin KD | last post by:
Hi everyone, I have a number of textboxes, lined up in a html table. I have split the table into different columns. The column widths are all relative, that is, % rather pixels or points so that it can grow / shrink. The textboxes are then placed into table cells and have their widths to be 100% of the width of their container (table cells). Example <table id="Table1" width="100%" ....> <tr> <td width="20%">First Label column</td>
1
15038
by: savajx1 | last post by:
I need to dynamically create a set of bound fields contained in a GridView control. I also have a single static CommandField that I can declare in the Columns <tagof the GridView control. I have to add controls dynamically as I am trying to write a reusable , general , spreadsheet like display control that can take advantage of the built- in update and delete features of the SqlDataSource/Gridview controls. This user control can get its...
1
1126
by: Jonathan | last post by:
I am new to Datagrids and asp.net (VB). In the sample code below, how do I set the Datagrid widths of the 4 columns I have from the query I have in the in the Access database? </head> <%@ Page language="VB" Debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %>
0
8198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8142
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8642
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8591
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5549
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4058
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.