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. 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. Doug
    Replies:
    1
    Views:
    3,999
    Rick Spiewak
    Apr 22, 2004
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,916
  3. schapopa
    Replies:
    1
    Views:
    579
    schapopa
    Jan 12, 2006
  4. H5N1
    Replies:
    0
    Views:
    2,741
  5. Les Caudle
    Replies:
    0
    Views:
    2,021
    Les Caudle
    May 2, 2006
Loading...

Share This Page