Thanks Phillip, I studied the example with ObjectDataSource but was hoping I
could implement this just using SqlDataSource.
I tried your selectedkeys.values[1] but still don't get any data in the ddl.
Here's my code:
<asp:GridView ID="RegistrantsGridView" runat="server"
DataSourceID="RegistrantsSqlDataSource"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
CssClass="waGridView"
DataKeyNames="RegistrantId" ... >
<Columns>
<asp:BoundField DataField="RegistrantId" HeaderText="Id"
InsertVisible="False" ReadOnly="True" SortExpression="RegistrantId" />
<asp:TemplateField>
<ItemTemplate>
<asp

ropDownList ID="RideDates" runat="server"
DataSourceId="RideDatesSqlDataSource">
</asp

ropDownList>
<asp:SqlDataSource ID="RideDatesSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:myDB %>"
ProviderName="System.Data.SqlClient"
SelectCommand="GetRegRideDates" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="RegistrantsGridView"
Name="RegistrantId"
PropertyName="SelectedDataKey.Values[1]" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ItemTemplate>
</TemplateField>
:
I have done it in this demo using an ObjectDataSource; where one of the
properties in the databound business class is a collection of the list items
specific to each row.
http://www.webswapp.com/codesamples/aspnet20/dropdownlist_gridview/default.aspx
If you want to do it using SQLDataSource, you will have to either intervene
during the RowUpdated event to trigger another SQL query that returns a list
of item that you bind to the dropdownlist or you can add the field that
determines the listitems selection process in the GridView. DataKeyNames then
set a SqlDataSource within the ItemTemplate with a parameter referencing that
datakey, e.g.
<asp:ControlParameter ControlID="GridView1" Name="CategoryID"
PropertyName="SelectedDataKey.Values[1]" Type="Int32" />
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
:
I have a dropdownlist in a GridView ItemTemplate. I need to bind the ddl to
an SqlDataSource, then have a value from a boundfield in the row be passed as
the keyfield for select where clause. Im trying to load the ddl with a list
of dates from another table keyed on GridView row field that only apply to
this row.
Any suggestions would be appreciated.