Results 1 to 2 of 2

Thread: User Control

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    User Control

    Hi!
    I am developing an asp.net application using c#.

    I have made a User Control which has a dropdownlist box. I have included that dropdownlist in my page through the following code in my page_load event.

    Code:
    Control myControl =(Control)Page.LoadControl (DropDownList.ascx"); 
    Panel1.Controls.Add(myControl);
    Now, I want to access the items of the dropdownlist in my page. How to do that.

    Viewing source of the page shows me this:

    HTML Code:
    <select name="_ctl0:cboDataBase" id="_ctl0_cboDataBase" style="width:144px;">
    		<option selected="selected" value="gsportal">gsportal</option>
    		<option value="test">test</option>
    </select>
    Thanks.

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: User Control

    Add a wrapped property to your user control that exposes the Items Property of your ddl. Then simply
    Code:
    TheUserControl ctl = (TheUserControl)FindControl("itsid");
    ctl.Item[0]....
    Magiaus

    If I helped give me some points.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width