Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. hyperlinkculumn in the grid

hyperlinkculumn in the grid

Scheduled Pinned Locked Moved ASP.NET
cssquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rameshdontagani
    wrote on last edited by
    #1

    hi i am creating the hyperlink column like this ........ HyperLinkColumn hlpField = new HyperLinkColumn(); hlpField.DataTextField = "test"; hlpField.HeaderText = "test"; datagrid.Columns.Add(hlpField); and now i want to give the url to this hyperlink field in the itemdatabound event...... how can i do this

    C K 2 Replies Last reply
    0
    • R rameshdontagani

      hi i am creating the hyperlink column like this ........ HyperLinkColumn hlpField = new HyperLinkColumn(); hlpField.DataTextField = "test"; hlpField.HeaderText = "test"; datagrid.Columns.Add(hlpField); and now i want to give the url to this hyperlink field in the itemdatabound event...... how can i do this

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Why are you adding it in code instead of in the aspx ? You can subscribe to the itemdatabound event and look for hte column there, but it would be better to build a template that just builds the URL

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • R rameshdontagani

        hi i am creating the hyperlink column like this ........ HyperLinkColumn hlpField = new HyperLinkColumn(); hlpField.DataTextField = "test"; hlpField.HeaderText = "test"; datagrid.Columns.Add(hlpField); and now i want to give the url to this hyperlink field in the itemdatabound event...... how can i do this

        K Offline
        K Offline
        Kodeeswaran
        wrote on last edited by
        #3

        Hi, instead of using hyperlink column, use linkbutton. find attached the code below. aspx file code: --------------- <asp:DataGrid DataKeyField="event_id" ID="eventsGrid" runat="server" CssClass="textbld" AllowSorting="True" AutoGenerateColumns="False" Width="518px" OnItemDataBound="eventsGrid_ItemDataBound" AlternatingItemStyle-CssClass="alternativeTxt" BorderColor="White" BorderStyle="Solid" BorderWidth="1px" CellPadding="0" HorizontalAlign="Left" > <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <EditItemStyle BackColor="#2461BF" /> <SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <AlternatingItemStyle CssClass="alternativeTxt" /> <ItemStyle HorizontalAlign="Left" CssClass="itemTxt" /> <Columns> <!-- Use the below variable event_id as hidden variables from the database--> <asp:BoundColumn DataField="event_id" Visible="False"></asp:BoundColumn> <!-- bind the hidden variable (event_id) value to the link button using "Eval" function--> <asp:TemplateColumn HeaderText="Ort" HeaderStyle-CssClass="padlist"> <ItemTemplate> <asp:LinkButton ID="lnkCity" runat="server" CommandArgument='<%# Eval("event_id") %>' OnCommand="lnkCity_Command" CssClass="Blacklink"></asp:LinkButton> </ItemTemplate> <ItemStyle CssClass="eventsTxt" /> </asp:TemplateColumn> </Columns> <HeaderStyle CssClass="head_txt Head_R1" /> </asp:DataGrid> .cs file code: --------------- In the onclick event of the linkbutton in the datagrid, give the link url as below. protected void lnkCity_Command(object sender, CommandEventArgs e) { Response.Redirect("Popup.aspx"); }

        Kodee

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups