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

Data Grid ASP.NET (Hypderlink query)

Options
  • 27-02-2006 4:29pm
    #1
    Registered Users Posts: 7,677 ✭✭✭


    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 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: 8,950 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