Reputation: 545
I have an asp:gridview populated with SQL (MSSQL 2008) data. The cells have naivgateurl fields so I can redirect users to a special page with some charts. Since there are multiple vehicles displayed in the table, I want users to get specific info on each vehicle when they click that specific row. So basically, I want the URL to go to ~\charts\load.aspx?ID=1 where 1 is the ID number of that car in the database. Can anyone point me in the right direction? I have seen some examples, but they are not related enough to my requirements for me to figure it out. My page uses C#. Thanks for any assistance!
Upvotes: 0
Views: 827
Reputation: 416
You could try something like this:
<asp:GridView ID="oGridView" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="oObjectDataSource" AutoGenerateColumns="False" Width="100%" CellPadding="3" PageSize="50" GridLines="None">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" HeaderStyle-HorizontalAlign="Left" ReadOnly="true" />
<asp:HyperLinkField DataNavigateUrlFields="CarID" DataNavigateUrlFormatString="/charts/load.aspx?ID={0}" DataTextField="CarName" HeaderText="CarName" SortExpression="CarName" HeaderStyle-HorizontalAlign="Left" />
</Columns>
<PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" />
</asp:GridView>
You'll need to:
I hope this is what you're looking for.
Cheers!
Upvotes: 1