473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 5331
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">This 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.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.

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">This 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:TemplateField HeaderText="Email" SortExpression="SEmail">
<EditItemTemplate>
<asp:TextBox Width="80px" CssClass="editfield" MaxLength="40"
ID="SEmail" runat="server" Text='<%# Bind("SEmail")%>'>
</asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label CssClass="displayfield" Width="80px" ID="SEmail"
runat="server" Text='<%# Eval("SEmail") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>

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="displayfield" text='<%# left( DataBinder.Eval(Container.DataItem,
"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">This 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:TemplateField HeaderText="Email" SortExpression="SEmail">
<EditItemTemplate>
<asp:TextBox Width="80px" CssClass="editfield" MaxLength="40"
ID="SEmail" runat="server" Text='<%# Bind("SEmail")%>'>
</asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label CssClass="displayfield" Width="80px" ID="SEmail"
runat="server" Text='<%# Eval("SEmail") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>

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.DataItem, "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="displayfield" text='<%# left( DataBinder.Eval(Container.DataItem,
"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">This 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:TemplateField HeaderText="Email" SortExpression="SEmail">
<EditItemTemplate>
<asp:TextBox Width="80px" CssClass="editfield" MaxLength="40"
ID="SEmail" runat="server" Text='<%# Bind("SEmail")%>'>
</asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label CssClass="displayfield" Width="80px" ID="SEmail"
runat="server" Text='<%# Eval("SEmail") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>

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.

Greg G.
Mar 19 '06 #5

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

Similar topics

3
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...
3
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...
1
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...
0
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...
1
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...
0
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...
1
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...
4
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...
0
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 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.