Nested Control in DataList

X

xs

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top