Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Data Grid ASP.NET (Hypderlink query)

  • 27-02-2006 03:29PM
    #1
    Registered Users, Registered Users 2 Posts: 8,679 ✭✭✭


    I have the following asp code for my datagrid.

    The text in red is the column that i want to retrieve the value selected and pass it back into my code in a Querystring as i will be building the page again but i will be using the value selected from the datagrid to use to retrieve information back from a database.

    I think i have to use something like a DataNavigateUrlFormatString.

    Can someone help me please.

    <asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False" AllowPaging="True" AllowCustomPaging="True">
    <Columns>
    <asp:HyperLinkColumn DataTextField="APTID" HeaderText="ID" NavigateUrl="AptMain.aspx"></asp:HyperLinkColumn>
    <asp:BoundColumn DataField="SNAME" HeaderText="Surname"></asp:BoundColumn>
    <asp:BoundColumn DataField="DATCRT" HeaderText="Created"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText="Policy">
    <ItemTemplate>
    <asp:HyperLink Runat="server" NavigateUrl='<%# "Details.aspx?BranchNo=" & Container.DataItem("POLBR") & "&ProductType=" & Container.DataItem("POLTY") & "&PolicyNumber=" & Container.DataItem("POLNO") %>' ID="Hyperlink1">
    <%# Container.DataItem("POLBR") & "-" & Container.DataItem("POLTY") & "-" & Container.DataItem("POLNO") %>
    </asp:HyperLink>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    <PagerStyle NextPageText="Next" PrevPageText="Previous"></PagerStyle>
    </asp:datagrid></TD>


Comments

  • Registered Users, Registered Users 2 Posts: 604 ✭✭✭Kai


    Try :

    http://www.c-sharpcorner.com/Code/2003/June/DataGridHyperLinkColumn.asp

    Google is the best developers aid, and its free :)


  • Moderators, Science, Health & Environment Moderators Posts: 9,223 Mod ✭✭✭✭mewso


    <asp:hyperlinkcolumn datanavigateurlfield="APTID" datanavigateurlformatstring="AptMain.aspx?id={0}"
    datatextfield="APTID" headertext="ID"></asp:hyperlinkcolumn>

    The datanavigateurlfield value specifies the column to insert into the {0} to create the querystring.
    datatextfield is the column to use as the text of the link.
    datanavigateurlformatstring = is the link to use.

    This is different to outputting one static url for each row.


Advertisement