Nested Control in DataList

Discussion in 'ASP .Net Web Controls' started by xs, Jun 11, 2004.

  1. xs

    xs Guest

    Hi All,

    I have a datalist that will display 2 controls, a dropdownlist and textbox
    when it is in edit mode. I have successfully bind the dropdownlist and
    textbox in the selected item in the datalist. Right now I would like the
    same textbox to reflect the changes in the dropdownlist. I have successfully
    added the "OnSelectedIndexChanged" event to the dropdownlist. However it
    will not update the textbox. I used the following code when the event is
    activated:

    protected void IndexChanged(object sender, System.EventArgs e)

    {

    TextBox tb = (TextBox)dl.SelectedItem.FindControl("txtCorrection");

    DropDownList drp =
    (DropDownList)dl.SelectedItem.FindControl("drpCorrection");

    tb.Text = drp.SelectedItem.Text;

    lbl.Text = drp.SelectedItem.Text;

    }

    But i can the following exception:

    Exception Details: System.NullReferenceException: Object reference not set
    to an instance of an object. Any ideas?
     
    xs, Jun 11, 2004
    #1
    1. Advertisements

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. Doug
    Replies:
    1
    Views:
    4,212
    Rick Spiewak
    Apr 22, 2004
  2. Nevyn Twyll
    Replies:
    8
    Views:
    2,324
  3. =?Utf-8?B?RGVyZWs=?=

    Accessing control in nested datalist

    =?Utf-8?B?RGVyZWs=?=, May 5, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,051
    Brock Allen
    May 5, 2005
  4. schapopa
    Replies:
    1
    Views:
    677
    schapopa
    Jan 12, 2006
  5. Mike
    Replies:
    1
    Views:
    1,962
    Keith Patrick
    Jan 12, 2006
  6. H5N1
    Replies:
    0
    Views:
    2,978
  7. Les Caudle
    Replies:
    0
    Views:
    2,201
    Les Caudle
    May 2, 2006
  8. Replies:
    3
    Views:
    9,158
    Eliyahu Goldin
    Sep 17, 2006
Loading...