Connecting Tech Pros Worldwide Forums | Help | Site Map

GridView Control - limiting width and overflow

GregG
Guest
 
Posts: n/a
#1: Mar 19 '06
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.

Ken Cox - Microsoft MVP
Guest
 
Posts: n/a
#2: Mar 19 '06

re: GridView Control - limiting width and overflow


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" <GregG@electron.com> wrote in message
news:r4np121j9msv0ehcdtkv4rvr23iknqetqm@4ax.com...[color=blue]
> 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.[/color]


GregG
Guest
 
Posts: n/a
#3: Mar 19 '06

re: GridView Control - limiting width and overflow


Ken Cox - Microsoft MVP said:
[color=blue]
>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][/color]

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,




[color=blue]
>
>"GregG" <GregG@electron.com> wrote in message
>news:r4np121j9msv0ehcdtkv4rvr23iknqetqm@4ax.com.. .[color=green]
>> 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.[/color]
>[/color]


Greg G.
Ken Cox - Microsoft MVP
Guest
 
Posts: n/a
#4: Mar 19 '06

re: GridView Control - limiting width and overflow


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" <GregG@electron.com> wrote in message
news:96rq12h4vfluv33glgeoik8u7096n146j9@4ax.com...[color=blue]
> Ken Cox - Microsoft MVP said:
>[color=green]
>>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][/color]
>
> 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,
>
>
>
>
>[color=green]
>>
>>"GregG" <GregG@electron.com> wrote in message
>>news:r4np121j9msv0ehcdtkv4rvr23iknqetqm@4ax.com. ..[color=darkred]
>>> 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.[/color]
>>[/color]
>
>
> Greg G.[/color]


GregG
Guest
 
Posts: n/a
#5: Mar 19 '06

re: GridView Control - limiting width and overflow



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...
[color=blue]
># left( DataBinder.Eval(Container.DataItem, "Longtext"),20)[/color]

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:
[color=blue]
>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" <GregG@electron.com> wrote in message
>news:96rq12h4vfluv33glgeoik8u7096n146j9@4ax.com.. .[color=green]
>> Ken Cox - Microsoft MVP said:
>>[color=darkred]
>>>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][/color]
>>
>> 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,
>>
>>
>>
>>
>>[color=darkred]
>>>
>>>"GregG" <GregG@electron.com> wrote in message
>>>news:r4np121j9msv0ehcdtkv4rvr23iknqetqm@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.
>>>[/color]
>>
>>
>> Greg G.[/color]
>[/color]


Greg G.
Closed Thread