I have some DropDownLists and some TextBoxes on a page. Normally I use this to clear and add value to the items:
Clear control:
txtEventNote.Text = String.Empty
ddlHours.SelectedIndex = 0
Add value:
ddlHours.SelectedValue = dtEvents.Rows(0)("EventDate")
txtEventTitle.Text = dtEvents.Rows(0)("EventHome").ToString()
But if I do this for items thats inside an ASP:LoginView I get an error because the ID’s cant be found.
So my question is:
-
How do I clear the
ddlSizeDropDownListID and how do i addString.EmptytotxtEventName.Textthat’s inside theLoginViewwhich has an ID of “loginview2”? -
And how do I add a value to a
TextBoxandDropDownListinside anLoginViewcalled “loginview2” where I have aTextBoxwith the ID textEventName.Text and theDropDownListhave ID ddlSize.
If I delete the LoginView it’s easy for me to do, but when I add the LoginView the ID’s can’t be found.
The
LoginViewcontrol is a container control. It can hold other ASP.NET WebForm controls. To get a reference to the controls contained within theLoginViewcontrol use theFindContolmethod of theLoginViewcontrol.Do the same for your
DropDownList.I found In Search Of ASP.Net Controls to be helpful for more about finding ASP.NET controls in other ASP.NET controls.