Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > HyperLinkColumn and column width

Reply
Thread Tools

HyperLinkColumn and column width

 
 
Atif Jalal
Guest
Posts: n/a
 
      02-05-2004
I am using a Datagrid control and one of its column is a
'HyperLinkColumn'. The link text for this HyperLinkColumn is sometimes
beyond 100 characters. I would like to display the link on multi-line
if the number of characters in the link exceed 100 characters. I tried
adding the <ItemStyle> to the HyperLinkColumn tag but it did not
work, the whole of the link is displayed on one line with the column
width getting extended.

<asp:HyperLinkColumn
DataNavigateUrlFormatString="'LineItem.aspx?LineIt emId={0}&Process=1&'"
DataNavigateUrlField="ProcessLineItemId" DataTextField="Description"
HeaderText="Line Item - Description">

<ItemStyle Width="100px" Wrap=True></ItemStyle>

</asp:HyperLinkColumn>

Is it that <ItemStyle> does not work with <asp:HyperLinkColumn> ? Any
help appreciated.
 
Reply With Quote
 
 
 
 
Scott
Guest
Posts: n/a
 
      02-06-2004
Atif, the HyperLinkColumn does not provide any property to limit the
number of characters. You will either have to:

(a) Use a TemplateColumn, calling some custom function to limit the
length. That is, you might have:

<asp:TemplateColumn>
<ItemTemplate>
<%# TruncateURL(DataBinder.Eval(Container.DataItem,
"Description"), DataBinder.Eval(Container.DataItem("ProcessLineIte mId"))
%>
</ItemTemplate>
</asp:TemplateColumn>

And then create a method in your code-behind class like:

Protected Function TruncateURL(desc as String, lineItemID as Integer)
as String
If desc.Length > 100 then
desc = desc.Substring(0, 95) & "..."
End If

Return "<a href=""LineItem.aspx?LineItemId=" & lineItemID &
"&Process=1"">" & desc & "</a>"
End Function


(b) Create a custom DataGridColumn class that can limit the number of
characters based on some property. There is an example of such a
class at:
http://aspnet.4guysfromrolla.com/articles/100202-1.aspx

hth


Scott Mitchell
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!


(E-Mail Removed) (Atif Jalal) wrote in message news:<(E-Mail Removed) m>...
> I am using a Datagrid control and one of its column is a
> 'HyperLinkColumn'. The link text for this HyperLinkColumn is sometimes
> beyond 100 characters. I would like to display the link on multi-line
> if the number of characters in the link exceed 100 characters. I tried
> adding the <ItemStyle> to the HyperLinkColumn tag but it did not
> work, the whole of the link is displayed on one line with the column
> width getting extended.
>
> <asp:HyperLinkColumn
> DataNavigateUrlFormatString="'LineItem.aspx?LineIt emId={0}&Process=1&'"
> DataNavigateUrlField="ProcessLineItemId" DataTextField="Description"
> HeaderText="Line Item - Description">
>
> <ItemStyle Width="100px" Wrap=True></ItemStyle>
>
> </asp:HyperLinkColumn>
>
> Is it that <ItemStyle> does not work with <asp:HyperLinkColumn> ? Any
> help appreciated.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
picture width decides table column width David Basford HTML 3 09-30-2007 10:49 PM
fixed-width column and variable-width columns mixed ssk HTML 5 10-30-2006 07:50 AM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM
DG Column Width vs Table Column Width Carl Howarth ASP .Net Datagrid Control 1 10-24-2004 08:48 AM
HyperLinkColumn and column width Atif Jalal ASP .Net 0 02-05-2004 02:51 PM



Advertisments