Results 1 to 2 of 2

Thread: Formatting DataGrid - Template column troubles

  1. #1

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Formatting DataGrid - Template column troubles

    I have a DataGrid that's bound to a DataSet, and I'd like to make one of the columns a hyperlink. I have this in the page
    Code:
    <asp:TemplateColumn HeaderText="Agency">
    	<ItemTemplate>
    		<asp:Label runat="server" Text='<%#  DataBinder.Eval(Container, "DataItem.Agency") %>'>
    		</asp:Label>
    	</ItemTemplate>
    I thought I could just change to something like
    Code:
    <asp:Label runat="server" Text='<%#  "<a href='Agencies.aspx'>" + DataBinder.Eval(Container, "DataItem.Agency") + "</a>" %>'>
    but I guess it doesn't like that, getting an error - "The server tag is not well formed." I'm thinking I may need to use something like Chr(62) for the greater than sign (well, not quite as using C#), but is that the workaround? Or is there another way?

    Thanks,
    Mike

  2. #2

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: Formatting DataGrid - Template column troubles

    Urgh. This is ugly. So far I have this
    Code:
    <asp:Label runat="server" Text='<%# ((char)60).ToString() + "a href=" + ((char)39).ToString() + "Agency.aspx?a=" + DataBinder.Eval(Container, "DataItem.Agency") + ((char)39).ToString() + ((char)62).ToString() + DataBinder.Eval(Container, "DataItem.Agency") + ((char)60).ToString() + "/a" + ((char)62).ToString() %>'>
    to come up with a string that ends up looking like
    Code:
    <a href='Agency.aspx?a=NM1234567'>NM1234567</a>
    If anyone has any suggestions, it'd be appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width