troubleshooting Question

DataNavigateUrlFormatString= only ever seems to open first record in dataset

Avatar of winstalla
winstallaFlag for United Kingdom of Great Britain and Northern Ireland asked on
Web Development.NET ProgrammingASP.NET
8 Comments1 Solution671 ViewsLast Modified:
I have created an ASP:Hyperlink field that turns the User Name field of my results page into a link. That works fine.
I have created a DataNavigateUrlFormatString= tag (is it a tag?) in the field to open a seperate ASPX page, which should list the details for that record.
However, no matter what I try, the link will only ever open the new page and display the first record in the dataset - even though the link when hovered or opened shows the correct information (e.g. shows a destination of http://ho-nas/guestbook2/tryread.aspx?Username=Bloggs,%20Joe)
Here is the code. (If any of the fields are duplicated that's because I've tried several ways of doing it and haven't deleted them, so they're an unintentional error on my part!)

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data.Oledb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>List of ALL Assets on Database</title>
    <link href="Styles/Site.css" rel="stylesheet" type="text/css" /></head>
<body>
'(There is a list of hyperlinks to other pages here - but they're not important, so I've removed them!)
    <form id="form1" runat="server">
    <div>

        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
            AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="AccessDataSource1">
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="ID" Visible="False" />
                    <asp:HyperLinkField
    DataNavigateUrlFields="username"
    DataNavigateUrlFormatString="tryread.aspx?Username={0}"
    DataTextField="UserName"
    HeaderText="User Name"
    SortExpression="UserName" />
                <asp:BoundField DataField="Make" HeaderText="Make" SortExpression="Make" />
                <asp:BoundField DataField="Model" HeaderText="Model" SortExpression="Model" />
                <asp:BoundField DataField="Serial" HeaderText="Serial" 
                    SortExpression="Serial" />
                <asp:BoundField DataField="Acquired" HeaderText="Acquired" 
                    SortExpression="Acquired" DataFormatString="{0:d MMMM yyyy}" />
                <asp:BoundField DataField="Expires" HeaderText="Expires" 
                    SortExpression="Expires" DataFormatString="{0:d MMMM yyyy}" />
                <asp:BoundField DataField="Condition" HeaderText="Condition" 
                    SortExpression="Condition" />
                <asp:BoundField DataField="Comments" HeaderText="Comments" 
                    SortExpression="Comments" />
                <asp:CheckBoxField DataField="Retired" HeaderText="Retired" 
                    SortExpression="Retired" />
            </Columns>
        </asp:GridView>
        <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
            DataFile="~/guestbook2/App_Data/TWIT.mdb" SelectCommand="SELECT * FROM [Requests]">
        </asp:AccessDataSource>

        </div>
    </form>
  </body>
</html>

I know it's bound to be something simple, but I don't know what!!!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros