468,115 Members | 2,036 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,115 developers. It's quick & easy.

SQLDataSource parameter referencing a text box in a user control?

I have a user control (.ascx) with a combo box in it. I place it and a
SQLDataSource control on a web form. I want a SQLDataSource parameter to
point to the combo box, but it seems that the control parameters can only see
controls in the same container.

<asp:ControlParameter ControlID="cboProjects"
Name="ProjectID" PropertyName="SelectedValue"
Type="Int32" />
The above works if cboProjects is in the same container, but not if it's in
the .ascx. I've tried various names in the ControlID value i.e.
mycontrol.cboProjects.

Is there any way to make this work? My only other idea is a hidden text
field and some code to fill it in. Not a very elegant solution, but I
haven't found anything better.

Thanks

Oct 16 '08 #1
2 3417
On Oct 16, 11:19*pm, VB.Net Pro <VBNet...@discussions.microsoft.com>
wrote:
I have a user control (.ascx) with a combo box in it. *I place it and a
SQLDataSource control on a web form. *I want a SQLDataSource parameter to
point to the combo box, but it seems that the control parameters can onlysee
controls in the same container.

* * * * * * * * <asp:ControlParameter ControlID="cboProjects"
Name="ProjectID" PropertyName="SelectedValue"
* * * * * * * * * * Type="Int32" />

The above works if cboProjects is in the same container, but not if it's in
the .ascx. *I've tried various names in the ControlID value i.e.
mycontrol.cboProjects. *

Is there any way to make this work? *My only other idea is a hidden text
field and some code to fill it in. *Not a very elegant solution, but I
haven't found anything better.

Thanks
ControlID="mycontrol$cboProjects"
Oct 18 '08 #2
Alexey,
Thank you for your answer, that did it!

"Alexey Smirnov" wrote:
On Oct 16, 11:19 pm, VB.Net Pro <VBNet...@discussions.microsoft.com>
wrote:
I have a user control (.ascx) with a combo box in it. I place it and a
SQLDataSource control on a web form. I want a SQLDataSource parameter to
point to the combo box, but it seems that the control parameters can only see
controls in the same container.

<asp:ControlParameter ControlID="cboProjects"
Name="ProjectID" PropertyName="SelectedValue"
Type="Int32" />

The above works if cboProjects is in the same container, but not if it's in
the .ascx. I've tried various names in the ControlID value i.e.
mycontrol.cboProjects.

Is there any way to make this work? My only other idea is a hidden text
field and some code to fill it in. Not a very elegant solution, but I
haven't found anything better.

Thanks

ControlID="mycontrol$cboProjects"
Oct 21 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Martin Bischoff | last post: by
9 posts views Thread by Dan Sikorsky | last post: by
3 posts views Thread by Ken Cox [Microsoft MVP] | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.