SqlDataSource param in ItemTemplate can't find GridView bound cont

G

Guest

I'm trying to load a DropDownList in a Gridview from a secondary
SqlDataSource but I get an exception complaining that the ControlParameter's
ControlId isn't found.
"Could not find control 'JoinDate' in ControlParameter 'JoinDate'."

<asp:BoundField DataField="JoinDate" HeaderText="Joined"
SortExpression="JoinDate" />
<asp:TemplateField HeaderText="Dates">
<ItemTemplate>
<asp:DropDownList ID="RideDatesDropDownList" runat="server"
OnDataBound="ShowHideDatesDDL"
DataSourceId="RideDatesSqlDataSource" DataTextField="RideDate"
DataValueField="RideDate"
DataTextFormatString="{0:MMM yyyy}" CssClass="waDropDownList">
</asp:DropDownList>
<asp:SqlDataSource ID="RideDatesSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:myDB %>"
ProviderName="System.Data.SqlClient"
SelectCommand="GetCurrentRidesTaken_desc"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="RegistrantIdLabel"
Name="RegistrantId" Type="Int32" />
<asp:ControlParameter ControlID="JoinDate" Name="JoinDate"
Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>

Any illumination would be appreciated, I'm stuck ;)
 
G

Guest

The BoundField object renders different objects based on the databound
control in which it is used. It is not a control that has an ID. You might
replace the BoundField with a TemplateField inside which you bind another
server control, e.g. a Label, give it an ID and refer to it using the
Controlparameter.
 
G

Guest

Super duper! I can do that.

Thanks much.

Phillip Williams said:
The BoundField object renders different objects based on the databound
control in which it is used. It is not a control that has an ID. You might
replace the BoundField with a TemplateField inside which you bind another
server control, e.g. a Label, give it an ID and refer to it using the
Controlparameter.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
 

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,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top