GridView help please

C

CK

Hi All,
I have a gridview that contains a column that has a repeater inside it. My
intent is to put every comment for an album into the repeater in the
comments column. I am using a SQLDataSource with a control parameter. The
parameter value is the outer gridview selected value. This of course onlys
gets the comments for the selected row. Can I use a property on like the row
databound event and get the datakey of the current row to use as the control
parameter. I have done this in c# before, but this project is for a friend
and it is written in VB. Any ideas?

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Name"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowSelectButton="True" />
<asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True"
SortExpression="Name" />
<asp:BoundField DataField="Year" HeaderText="Year" SortExpression="Year" />
<asp:BoundField DataField="Band" HeaderText="Band" SortExpression="Band" />
<asp:BoundField DataField="Genre" HeaderText="Genre" SortExpression="Genre"
/>
<asp:HyperLinkField HeaderText="Comment" Text="comments"
DataNavigateUrlFields="Name"
DataNavigateUrlFormatString="~/Admin/ViewComments.aspx?AlbumParameter={0}"
/>
<asp:HyperLinkField HeaderText="Rating" Text="Rating"
DataNavigateUrlFields="Name"
DataNavigateUrlFormatString="~/Admin/ViewRatings.aspx?AlbumParameter={0}" />
<asp:TemplateField>
<ItemTemplate>
<asp:Repeater runat="server" DataSourceID="SqlDataSource3" ID="rptr1">
<ItemTemplate>
<%# Eval("Comment") %><br />
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Here is the sqldatasource

<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$
ConnectionStrings:DataBaseMDF %>"
SelectCommand="SELECT Comment FROM Comments WHERE (AlbumName = @AlbumName)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="AlbumName"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top