Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Data Grid ASP.NET (Hypderlink query)

  • 27-02-2006 3:29pm
    #1
    Registered Users, Registered Users 2 Posts: 7,989 ✭✭✭


    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,035 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