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?
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?