Gridview linking to detailsview on a different page

Hi

Im fairly new to .net so apologise if this is a simple request!

I have a simple page with a GridView control getting data from a sql database.
I have added a hyperlink as below
<asp:HyperLinkField Text=“Select” DataNavigateUrlFields=“title_id” DataNavigateUrlFormatString=“title.aspx?id={0}” />

On my title.aspx page, i have a detailsview control and i want to be able to retrieve information using the id from the gridview hyperlink.

Thanks in advance for any help :slight_smile:

This would usually be done my passing the id querystring parameter into your DataSource. Something like:

[COLOR=#646464]


<asp:SqlDataSource
             ID="SqlDataSource1"
             runat="server"
             ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
             DataSourceMode="DataReader"
             SelectCommand="SELECT ProductID, ProductName, UnitPrice FROM Products WHERE ProductID=@ProductID"
             >
             <SelectParameters>
                <asp:QueryStringParameter Name="ProductID" QueryStringField="QSProductID" />
             </SelectParameters>
        </asp:SqlDataSource>
        <asp:DetailsView
             ID="DetailsView1"
             runat="server"
             DataSourceID="SqlDataSource1"
             BackColor="HotPink"
             ForeColor="AliceBlue"
             ></asp:DetailsView>

[/COLOR]What type of DataSource is your DetailsView using?

thats great thanks. Working now :slight_smile:

If you want to get it server side. You can use Request.QueryString[“id”];

Just so that you know