Results 1 to 4 of 4

Thread: [RESOLVED] gridview column hyperlinks

  1. #1

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Resolved [RESOLVED] gridview column hyperlinks

    Hi,

    I would like to transform the data in the column into hyper link.
    let's say if i have "apple" in my column , when clicked on it i wud like it to go to "microsoft.com/apple" . Any tip will be apprciated. THx

    my current gridview code looks like this

    <asp:TemplateField HeaderText="Status">
    <EditItemTemplate>
    <asp:TextBox ID="txtStatus" runat="server" Text='<&#37;# Bind("Status") %>' Width="60" Font-Size="8" Font-Names="tahoma" ></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label12" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
    </ItemTemplate>
    </asp:TemplateField>
    Last edited by met0555; Dec 21st, 2011 at 06:46 PM.

  2. #2

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: gridview column hyperlinks

    ok,

    i managed to replace the string to hyperlink with the following code
    vb Code:
    1. <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("status") %>' NavigateUrl="#"></asp:HyperLink>

    instead of
    vb Code:
    1. <asp:Label ID="Label12" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
    but don't know how to get the value of the string ex: microsoft.com\thevalue


    thx

  3. #3

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: gridview column hyperlinks

    i got it working with the following code

    vb Code:
    1. <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Bind("[CLIENT]") %>' Target="_blank" NavigateUrl='<%# "https://xxxxxxxxxxxxxxxx?txtxxxxxxxx=" + Eval("Client")%>'></asp:HyperLink>

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] gridview column hyperlinks

    Hello,

    I would strongly encourage you to do this work in the code behind for the application page, rather than bind it in the ASPX markup. The code you are creating belongs there, and it allows for a cleaner separation between your UI and the code.

    Gary

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