|
| Gridview word wrap issue |
 |
Thu, 3 Apr 2008 17:13:37 +0000 |
Hi, I have a gridview that I am having some trouble formatting in firefox.
I have a row called "URL" that can contain long fields like
http://test.grovest.com?variables=8324723984723984723948732948372948274923847239
8
(note the lack of a space character)
In IE, I can set the width of the gridview and it inserts breaks into the fields
automattically.
However, in firefox the field never breaks in the gridview cell and makes the
gridview realllllllly long.
Is there a way for me to make this cell have a certain width in firefox?
|
| Post Reply
|
| Re: Gridview word wrap issue |
 |
Thu, 3 Apr 2008 20:43:18 +0000 |
create a function that splits the value
<asp:gridviewid="GridView"runat="server" ..>
<Columns>
<asp:templatefield>
<itemtemplate><%# truncate(DataBinder.Eval(Container,
"DataItem.Column").ToString, MaxChars)%>
</itemtemplate>
...</asp:gridview>
Function truncate(ByVal originalInput As System.String,ByVal MaxChars as
integer) As System.String
IfNot originalInput IsNothingAndAlso originalInput <> ""Then
If originalInput.Length > MaxChars Then
IfNot originalInput.Substring(0, MaxChars).Contains(" ") ThenReturn
originalInput.Substring(0, MaxChars) + " " +
originalInput.Substring(MaxChars)
ElseReturn originalInput
EndIf
ElseReturn originalInput
EndIf
EndIf
Return""
EndFunction
|
| Post Reply
|
| Re: Gridview word wrap issue |
 |
Thu, 3 Apr 2008 20:56:36 +0000 |
perhaps there is a more elegant way of doing this?
|
| Post Reply
|
| Re: Gridview word wrap issue |
 |
Thu, 3 Apr 2008 21:10:10 +0000 |
i will have to test it becuase i always forget this but i dont thing firefox
respect this Wrap="true"
<asp:boundfieldHeaderText="Somefield"DataField="Somefield&quo
t; >
<ItemStyleHorizontalAlign="Left"Width="80px"Wrap="tr
ue"/>
</asp.boundfield>
alternatively use Rowcreated function of gridview
Sub RowCreated(ByVal sender AsObject, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = System.Web.UI.WebControls.DataControlRowType.DataRow Then
..... mulipulate teh value of cell here
end if
end sub
|
| Post Reply
|
| Re: Gridview word wrap issue |
 |
Thu, 3 Apr 2008 22:01:26 +0000 |
hi!
i don't know much about elegance 'cause most of time I am dealing with clientS
that want first functionality so consider this...
<asp:Panel ID="Panel1" runat="server"
ScrollBars="Auto" width="100%">
<asp:GridView ID="GridView1"
runat="server"></asp:GridView>
</asp:Panel>
ciao ;-)
|
| Post Reply
|
|
|
|
|
|
|
|
|
|