How do I add a value to a TextBox that's inside an ASP:LoginView

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 ddlSize DropDownList ID and how do i add String.Empty to txtEventName.Text that's inside the LoginView which has an ID of "loginview2"?

  • And how do I add a value to a TextBox and DropDownList inside an LoginView called "loginview2" where I have a TextBox with the ID textEventName.Text and the DropDownList have 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 LoginView control is a container control. It can hold other ASP.NET WebForm controls. To get a reference to the controls contained within the LoginView control use the FindContol method of the LoginView control.

TextBox tb = lcLoginView.FindControl("txtEventNote") as TextBox
if (tb != null)
     tb.Text = "My New Value For This TextBox control";

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.

Need Your Help

Display image on scaled size imageView from gallery

android imageview gallery

I want to display iamge on imageView from gallery.

Error while using stastmodels' WLS: SVD did not converge

python numpy classification linear-regression training-data

I've written an algorithm for a cascaded boosting classifier using WLS (weighted least squares regression) in statsmodels, and have been able to successfully run it a few times. I used it with a few

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.