using controls in user control as control parameters on parent page

H

HP

hi there

Is it possible to bind a datasource to a dropdownlist contained in a
user control if datasource is positioned on the parent page of user
control?
I guess not, since user control doesn't appear when I'm selecting
control parameters for datasource in a designer, right?
But what's the alternative? Should I create custom parameter (like
this: http://www.leftslipper.com/ShowFaq.aspx?FaqId=11) inside the
user control class?

thanks
HP
 
H

HP

Hi,
Yes you can do it through properties.Suppose in UserControl class you create
following property:

private DataSet x;
public DataSet SetDataSource
{
get
{
return x;
}
set
{
x = value;
}
}

In the parent page you can write following:

UserControlInstance.SetDataSource = ds(a dataset variable)
Hope this has cleared your doubt.


Sorry, I forgot to mention, that I wanted to do it with declarative
DataBinding.

thanks
HP
 
G

Guest

Hi,
Yes you can do it.You can write following code in parent page:

DropDownList ctrldrp =(DropDownList)
UserControlInstance.FindControl("DropDownListName")
ctrldrp.DataSource = ds( a dataset variable)

I think this is what you are looking for.

Thanks and Regards,
manish bafna
 
H

HP

Hi,
Yes you can do it.You can write following code in parent page:

DropDownList ctrldrp =(DropDownList)
UserControlInstance.FindControl("DropDownListName")
ctrldrp.DataSource = ds( a dataset variable)

Yes, but I was thinking about declarative databinding (i.e. choosing
ddl as a source for select parameter of datasource control in the
visual studio designer).

thanks
HP
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,087
Latest member
JeremyMedl

Latest Threads

Top