Accessing a drop down in a form view from a user control

Discussion in 'ASP .Net' started by Larry Bud, Dec 20, 2006.

  1. Larry Bud

    Larry Bud Guest

    Main page has a FormView, and within that, is a drop down.

    A user control is on the page

    >From the user control, I need access to the drop down value. I can get

    to it like this

    Dim cc As FormView, dd As DropDownList

    cc = Parent.FindControl("FormView1")
    dd = cc.FindControl("currency_code")

    exchange_rate.Text = dd.SelectedValue

    Is there a more direct route?
     
    Larry Bud, Dec 20, 2006
    #1
    1. Advertising

  2. Larry Bud

    Mark Rae Guest

    "Larry Bud" <> wrote in message
    news:...

    > Main page has a FormView, and within that, is a drop down.
    >
    > A user control is on the page
    >
    >>From the user control, I need access to the drop down value. I can get

    > to it like this
    >
    > Dim cc As FormView, dd As DropDownList
    >
    > cc = Parent.FindControl("FormView1")
    > dd = cc.FindControl("currency_code")
    >
    > exchange_rate.Text = dd.SelectedValue
    >
    > Is there a more direct route?


    Have you tried

    exchange_rate.Text = currency_code.SelectedValue

    ?
     
    Mark Rae, Dec 20, 2006
    #2
    1. Advertising

  3. Larry Bud

    Larry Bud Guest

    Mark Rae wrote:
    > "Larry Bud" <> wrote in message
    > news:...
    >
    > > Main page has a FormView, and within that, is a drop down.
    > >
    > > A user control is on the page
    > >
    > >>From the user control, I need access to the drop down value. I can get

    > > to it like this
    > >
    > > Dim cc As FormView, dd As DropDownList
    > >
    > > cc = Parent.FindControl("FormView1")
    > > dd = cc.FindControl("currency_code")
    > >
    > > exchange_rate.Text = dd.SelectedValue
    > >
    > > Is there a more direct route?

    >
    > Have you tried
    >
    > exchange_rate.Text = currency_code.SelectedValue


    Yes, I have. Compilation error, "currency_code not declared."
     
    Larry Bud, Dec 20, 2006
    #3
  4. Larry Bud

    Larry Bud Guest

    Mark Rae wrote:
    > "Larry Bud" <> wrote in message
    > news:...
    >
    > > Main page has a FormView, and within that, is a drop down.
    > >
    > > A user control is on the page
    > >
    > >>From the user control, I need access to the drop down value. I can get

    > > to it like this
    > >
    > > Dim cc As FormView, dd As DropDownList
    > >
    > > cc = Parent.FindControl("FormView1")
    > > dd = cc.FindControl("currency_code")
    > >
    > > exchange_rate.Text = dd.SelectedValue
    > >
    > > Is there a more direct route?

    >
    > Have you tried
    >
    > exchange_rate.Text = currency_code.SelectedValue


    Yes, I have. Compilation error, "currency_code not declared."
     
    Larry Bud, Dec 20, 2006
    #4
  5. Larry Bud

    Mark Rae Guest

    "Larry Bud" <> wrote in message
    news:...

    > Mark Rae wrote:
    >> "Larry Bud" <> wrote in message
    >> news:...
    >>
    >> > Main page has a FormView, and within that, is a drop down.
    >> >
    >> > A user control is on the page
    >> >
    >> >>From the user control, I need access to the drop down value. I can get
    >> > to it like this
    >> >
    >> > Dim cc As FormView, dd As DropDownList
    >> >
    >> > cc = Parent.FindControl("FormView1")
    >> > dd = cc.FindControl("currency_code")
    >> >
    >> > exchange_rate.Text = dd.SelectedValue
    >> >
    >> > Is there a more direct route?

    >>
    >> Have you tried
    >>
    >> exchange_rate.Text = currency_code.SelectedValue

    >
    > Yes, I have. Compilation error, "currency_code not declared."


    OK then - have you tried prefixing currency_code.SelectedValue with the id
    of the custom control...?
     
    Mark Rae, Dec 20, 2006
    #5
    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. SirPoonga
    Replies:
    2
    Views:
    783
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    1,035
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    498
    msimmons
    Jul 16, 2009
  4. Replies:
    5
    Views:
    284
  5. Replies:
    3
    Views:
    297
Loading...

Share This Page