using controls in user control as control parameters on parent page

Discussion in 'ASP .Net' started by HP, Dec 11, 2006.

  1. HP

    HP Guest

    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
     
    HP, Dec 11, 2006
    #1
    1. Advertising

  2. HP

    HP Guest

    Re: using controls in user control as control parameters on parent pag

    > 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
     
    HP, Dec 12, 2006
    #2
    1. Advertising

  3. Re: using controls in user control as control parameters on parent

    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

    "HP" wrote:

    > > 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
    >
    >
     
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=, Dec 12, 2006
    #3
  4. HP

    HP Guest

    Re: using controls in user control as control parameters on parent

    > 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
     
    HP, Dec 19, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    Access User Control DataGrid Controls from parent page

    =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Feb 16, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    873
    IPGrunt
    Feb 16, 2005
  2. Faizan Ahmed
    Replies:
    1
    Views:
    299
    John Saunders
    Jan 4, 2005
  3. Faizan Ahmed
    Replies:
    1
    Views:
    376
    John Saunders
    Jan 4, 2005
  4. hmikki
    Replies:
    1
    Views:
    148
    Nathan Sokalski
    Oct 19, 2007
  5. Bill S.
    Replies:
    2
    Views:
    228
    Bill S.
    May 8, 2004
Loading...

Share This Page