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

Home Posts Topics Members FAQ

GridView Control - limiting width and overflow

Greetings,

I have been working with the new GridView control, and while figuring
out most of it's idiosyncrasies on my own, have stumbled upon a
problem I cannot seem to resolve.

We have table displayed in a GV control.
It allows for editing and selecting, etc.
Some of the fields are 60 characters long, but only the first 20 or so
are relevant, and all of them have to fit on one line within the row -
with the overflow being hidden and not wrapped.

So...
What we need is to be able to clip the overflow of a predefined width
that is assigned to each column.

Any thoughts?
Thanks,
Greg G.
Mar 19 '06 #1
4 5347
Hi Greg,

When you create the textbox in the template, can you set its columns
property to the number of characters you want to view?

<asp:textbox id="TextBox1" runat="server" columns="20">Th is is a very
long string of which only the first twenty are relevant</asp:textbox>

Perhaps I missed your point?

Ken
Microsoft MVP [ASP.NET]

"GregG" <Gr***@electron .com> wrote in message
news:r4******** *************** *********@4ax.c om...
Greetings,

I have been working with the new GridView control, and while figuring
out most of it's idiosyncrasies on my own, have stumbled upon a
problem I cannot seem to resolve.

We have table displayed in a GV control.
It allows for editing and selecting, etc.
Some of the fields are 60 characters long, but only the first 20 or so
are relevant, and all of them have to fit on one line within the row -
with the overflow being hidden and not wrapped.

So...
What we need is to be able to clip the overflow of a predefined width
that is assigned to each column.

Any thoughts?
Thanks,
Greg G.

Mar 19 '06 #2
Ken Cox - Microsoft MVP said:
Hi Greg,

When you create the textbox in the template, can you set its columns
property to the number of characters you want to view?

<asp:textbox id="TextBox1" runat="server" columns="20">Th is is a very
long string of which only the first twenty are relevant</asp:textbox>

Perhaps I missed your point?

Ken
Microsoft MVP [ASP.NET]
This is my second call for help (the first got no replies), and in my
desire to keep it short, I snipped some of the relevent text... As
per the snippet below, this is an example TemplateField entry for one
field.. There are other fields, several of which are NOT to be
editable. The reasons for this are that different users have
differing levels of editing capability, depending on their company
department.

It's not a problem to limit the columns in edit mode, when using a
textbox. But where the text is _only_ displayed, we don't want
textboxes, but labels - or other non-editable entity.
As below: (watch the word wrap...)

<asp:TemplateFi eld HeaderText="Ema il" SortExpression= "SEmail">
<EditItemTempla te>
<asp:TextBox Width="80px" CssClass="editf ield" MaxLength="40"
ID="SEmail" runat="server" Text='<%# Bind("SEmail")% >'>
</asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label CssClass="displ ayfield" Width="80px" ID="SEmail"
runat="server" Text='<%# Eval("SEmail") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>

I could be overlooking something obvious, as I've only been using
ASP.Net2 for a week, but have a pretty extensive background in ASP,
HTML, VBA/Access, etc.

We got it to work in IE using DIV wrappers around the label contents
and applying a CSS style containing explicit width, overflow: hidden
and nowrap, but it breaks in Firefox, NS - which stretches the text
full length and stretches the gridview WAAAY off-screen.

I hate tables and stopped using them years ago, but tables are what
the GV control generates... ;-)

I'd show you an example online, but I'm afraid of the traffic it would
generate on our server...

Thanks,



"GregG" <Gr***@electron .com> wrote in message
news:r4******* *************** **********@4ax. com...
Greetings,

I have been working with the new GridView control, and while figuring
out most of it's idiosyncrasies on my own, have stumbled upon a
problem I cannot seem to resolve.

We have table displayed in a GV control.
It allows for editing and selecting, etc.
Some of the fields are 60 characters long, but only the first 20 or so
are relevant, and all of them have to fit on one line within the row -
with the overflow being hidden and not wrapped.

So...
What we need is to be able to clip the overflow of a predefined width
that is assigned to each column.

Any thoughts?
Thanks,
Greg G.

Greg G.
Mar 19 '06 #3
How about just trimming off the characters that you don't want?

<itemtemplate >
<asp:label id="Longtext" runat="server"
cssclass="displ ayfield" text='<%# left( DataBinder.Eval (Container.Data Item,
"Longtext") ,20) %>'
width="80px">
</asp:label>
</itemtemplate>
"GregG" <Gr***@electron .com> wrote in message
news:96******** *************** *********@4ax.c om...
Ken Cox - Microsoft MVP said:
Hi Greg,

When you create the textbox in the template, can you set its columns
property to the number of characters you want to view?

<asp:textbox id="TextBox1" runat="server" columns="20">Th is is a very
long string of which only the first twenty are relevant</asp:textbox>

Perhaps I missed your point?

Ken
Microsoft MVP [ASP.NET]


This is my second call for help (the first got no replies), and in my
desire to keep it short, I snipped some of the relevent text... As
per the snippet below, this is an example TemplateField entry for one
field.. There are other fields, several of which are NOT to be
editable. The reasons for this are that different users have
differing levels of editing capability, depending on their company
department.

It's not a problem to limit the columns in edit mode, when using a
textbox. But where the text is _only_ displayed, we don't want
textboxes, but labels - or other non-editable entity.
As below: (watch the word wrap...)

<asp:TemplateFi eld HeaderText="Ema il" SortExpression= "SEmail">
<EditItemTempla te>
<asp:TextBox Width="80px" CssClass="editf ield" MaxLength="40"
ID="SEmail" runat="server" Text='<%# Bind("SEmail")% >'>
</asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label CssClass="displ ayfield" Width="80px" ID="SEmail"
runat="server" Text='<%# Eval("SEmail") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>

I could be overlooking something obvious, as I've only been using
ASP.Net2 for a week, but have a pretty extensive background in ASP,
HTML, VBA/Access, etc.

We got it to work in IE using DIV wrappers around the label contents
and applying a CSS style containing explicit width, overflow: hidden
and nowrap, but it breaks in Firefox, NS - which stretches the text
full length and stretches the gridview WAAAY off-screen.

I hate tables and stopped using them years ago, but tables are what
the GV control generates... ;-)

I'd show you an example online, but I'm afraid of the traffic it would
generate on our server...

Thanks,



"GregG" <Gr***@electron .com> wrote in message
news:r4****** *************** ***********@4ax .com...
Greetings,

I have been working with the new GridView control, and while figuring
out most of it's idiosyncrasies on my own, have stumbled upon a
problem I cannot seem to resolve.

We have table displayed in a GV control.
It allows for editing and selecting, etc.
Some of the fields are 60 characters long, but only the first 20 or so
are relevant, and all of them have to fit on one line within the row -
with the overflow being hidden and not wrapped.

So...
What we need is to be able to clip the overflow of a predefined width
that is assigned to each column.

Any thoughts?
Thanks,
Greg G.

Greg G.

Mar 19 '06 #4

Ken,

I had considered that method, but thought there might be a better,
more elegant way. The DIV method I mentioned allowed the boxes to
resize as a product of browser window resizing (they were defined as
percentages), whereas this approach wouldn't.

But at this point, I guess the cross-browser compatibility is going to
take precedence over style... Again...
# left( DataBinder.Eval (Container.Data Item, "Longtext") ,20)
Gee, what happened to Left([FieldName],20) ;-)

It'll take me a week to absorb this particular object's hierarchy.
What I _really_ need is a wall sized chart that breaks out the huge
number of objects and their properties/methods/etc/etc.

Thanks,
Greg


Ken Cox - Microsoft MVP said:
How about just trimming off the characters that you don't want?

<itemtemplate >
<asp:label id="Longtext" runat="server"
cssclass="disp layfield" text='<%# left( DataBinder.Eval (Container.Data Item,
"Longtext"),20 ) %>'
width="80px">
</asp:label>
</itemtemplate>
"GregG" <Gr***@electron .com> wrote in message
news:96******* *************** **********@4ax. com...
Ken Cox - Microsoft MVP said:
Hi Greg,

When you create the textbox in the template, can you set its columns
property to the number of characters you want to view?

<asp:textbox id="TextBox1" runat="server" columns="20">Th is is a very
long string of which only the first twenty are relevant</asp:textbox>

Perhaps I missed your point?

Ken
Microsoft MVP [ASP.NET]


This is my second call for help (the first got no replies), and in my
desire to keep it short, I snipped some of the relevent text... As
per the snippet below, this is an example TemplateField entry for one
field.. There are other fields, several of which are NOT to be
editable. The reasons for this are that different users have
differing levels of editing capability, depending on their company
department.

It's not a problem to limit the columns in edit mode, when using a
textbox. But where the text is _only_ displayed, we don't want
textboxes, but labels - or other non-editable entity.
As below: (watch the word wrap...)

<asp:TemplateFi eld HeaderText="Ema il" SortExpression= "SEmail">
<EditItemTempla te>
<asp:TextBox Width="80px" CssClass="editf ield" MaxLength="40"
ID="SEmail" runat="server" Text='<%# Bind("SEmail")% >'>
</asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label CssClass="displ ayfield" Width="80px" ID="SEmail"
runat="server" Text='<%# Eval("SEmail") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>

I could be overlooking something obvious, as I've only been using
ASP.Net2 for a week, but have a pretty extensive background in ASP,
HTML, VBA/Access, etc.

We got it to work in IE using DIV wrappers around the label contents
and applying a CSS style containing explicit width, overflow: hidden
and nowrap, but it breaks in Firefox, NS - which stretches the text
full length and stretches the gridview WAAAY off-screen.

I hate tables and stopped using them years ago, but tables are what
the GV control generates... ;-)

I'd show you an example online, but I'm afraid of the traffic it would
generate on our server...

Thanks,



"GregG" <Gr***@electron .com> wrote in message
news:r4***** *************** ************@4a x.com...
Greetings,

I have been working with the new GridView control, and while figuring
out most of it's idiosyncrasies on my own, have stumbled upon a
problem I cannot seem to resolve.

We have table displayed in a GV control.
It allows for editing and selecting, etc.
Some of the fields are 60 characters long, but only the first 20 or so
are relevant, and all of them have to fit on one line within the row -
with the overflow being hidden and not wrapped.

So...
What we need is to be able to clip the overflow of a predefined width
that is assigned to each column.

Any thoughts?
Thanks,
Greg G.

Greg G.

Greg G.
Mar 19 '06 #5

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

Similar topics

3
3988
by: Joseph Gordon | last post by:
I need to "freeze" the headers for a webforms gridview. I have found no documentation or articles that explain how to accomplish this using the ASP.NET 2.0 GridView control. I really prefer not to have to add this functionality myself as I had to in the 1.1 framework, please tell me it's built-in. Thanks, -JGordon-
3
4859
by: RCS | last post by:
Perhaps you are familiar with the old: <nobr style="OVERFLOW:hidden;width:100px;TEXT-OVERFLOW:ellipsis">blah blah blahblah blah blah blah</nobr> technique.. Well, within a gridview, if I use this technique for a field, it just sort of ignores it. If I isolate out this line in a seperate .html file, it works as expected. Also, if I do a view source on the resultant output from my .aspx page - it seems like it should work. For example,...
1
9358
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes GridView.Visible = True. I press HIDE and the GridView disappears as expected. After it I press SHOW and the GridView doesn't show.
0
1890
by: GregG | last post by:
Greetings, I have been fighting with the new GridView control, and while figuring out most of it's idiosyncrasies on my own, have stumbled upon a problem I cannot seem to resolve. We have table displayed in a GV control. It allows for editing and selecting, etc. Some of the fields are 60 characters long, but only the first 20 or so are relevant, and all of them have to fit on one line within the row -
1
2878
by: Bill44077 | last post by:
I am dynamically adding a checkbox in a gridview and I find there are several things that I cannot figure out how to address. 1. The width of the checkbox column is very wide. I've tried adding properties and Item Style to the column but it has no effect. Is there someway to size this column to be smaller? I removed the CssClass property and it had no effect on the size as well. 2. The gridview is sortable using javascript. Is there...
0
1659
by: John Smith | last post by:
If anyone can help, I would very muchly appreciate it. I have a main page that uses the .net 2.0 menu control with the multiview controls as the menu choices. This works fine. One of the menu choices dynamically loads a user control with a gridview (datagrid) control on it. That works fine. The problem arises when the user clicks on a different page of the gridview control---this is a paged gridview. When that happens, the gridview...
1
15046
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...
4
8762
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I setup a simple gridview as a utility just to do some updates, nothing fancy just wanted easy UI to make updates. When I select ‘Edit’, I get the fields I want to edit. I edit them and click ‘Update’, the page returns to its original state (prior to clicking Edit) and no updates occur in the DB. What am I missing? I included the html code below. -- Thank-you, Barbara Alderton <body>
0
1919
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I am using a CssClass to fix the gridview header in ASP.Net 2005(C#),which is working fine in IE..But not working in Firefox..This is the cssclass which I'm using right now WrapperDiv { background-image: url(tdbg.jpg); color: #002F5C;
0
10456
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
10230
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...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
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
6788
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
5442
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...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.