Click to See Complete Forum and Search --> : ASP.Net Datagrid drill down


seafordcrownfc
12-05-2007, 11:14 AM
All the tutorials I have looked through so far haven't helped me with what I am looking for.

I have an ASP.Net page (results1.aspx) which currently has the following datagrid :

<asp:GridView ID="GridViewResults" runat="server" AutoGenerateColumns="False" DataSourceID="AccessDataSource2" OnSelectedIndexChanged="GridViewResults_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="matchdate" HeaderText="Date / Kick Off" SortExpression="matchdate" />
<asp:BoundField DataField="opposition" HeaderText="Opposition" SortExpression="opposition" />
<asp:BoundField DataField="venue" HeaderText="Venue" SortExpression="venue" />
<asp:BoundField DataField="Score" HeaderText="Score" SortExpression="Score" />
<asp:BoundField DataField="competitionname" HeaderText="Comp" SortExpression="competitionname" />
<asp:BoundField DataField="competitionround" HeaderText="Comp Rnd" NullDisplayText="-" SortExpression="competitionround" />
<asp:BoundField DataField="wld" HeaderText="W/L/D" SortExpression="wld" />
<asp:HyperLinkField />
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/stfc.mdb"
SelectCommand="SELECT sm.matchID, sm.opposition, sm.venue, sm.matchdate, c.competitionname, sm.competitionround, sm.goalsfor + '-' + sm.goalsagainst AS Score, sm.wld FROM competition AS c, stfcmatch AS sm WHERE c.competitionid=sm.competitionid AND sm.teamtype='First' AND sm.matchdate < DATE()">
</asp:AccessDataSource>

I want the hyperlink field to work so that when the user click on it, it will open up a new page (matchdetails.aspx) which displays the match report from that record, which is in the field [matchreport] in the [stfcmatch] table.

It seems really simple but I just cant work it out for love nor money.

Thanks,

Dan

lmf232s
12-11-2007, 10:43 PM
You need to add a template field to the gridview. Im typing this out so it might have a problem or 2 but this is what you need to do. Let me know if you have problems.

<asp:TemplateField>
<ItemTemplate>
<asp:Hyperlink id="lnkNavigate" runat="server" Text='<%# Eval("SomeText") %>' NavigateUrl='<%# "matchdetails.aspx?Id=" & Eval("IdField") %>' target="_Blank"/>
</ItemTemplate>
</asp:TemplateField>

seafordcrownfc
12-12-2007, 07:15 AM
Thanks for this. I have managed to get it working now with the help of this.