Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placeholder Problems

Status
Not open for further replies.

emblewembl

Programmer
May 16, 2002
171
GB
Hi, I am building a form which will load each element dynamically into placeholders. However I am having trouble finding out how to collect the values once the form has been posted. I am building a dropdownlist from some data and binding it to my placeholder as follows:
Code:
    FindCust.DataSource = OurDataReader
    FindCust.DataTextField = "Customer_Name"
    FindCust.DataValueField = "Sales_Ledger_Code"
    FindCust.Autopostback = true
    FindCust.Databind()
    CustPlaceHolder.Controls.Add(FindCust)
In my page_load sub I am using 'If IsPostBack Then...' and then trying to collect the value that was selected as follows:
Code:
CustFound.Text = &quot;Text : &quot; & FindCust.SelectedItem.Text & &quot;<br>&quot;
... where CustFound is the name of a label on my page. However I am just getting an error message to say that 'FindCust has not been declared', even though in my sub where I build the text box it is declared as follows:
Code:
Dim FindCust As new DropDownList()
If I remove the line where I try to collect the values the page loads fine. This is driving me mad!!!!!! Please help......
i love chocolate
 
Just an idea. Since the first loading doesn't see &quot;If IsPostback&quot; any declarations there will probably not be seen when the page first loads. Try putting the declaration immediately after the Page_Load statement.
 
Try giving the declaration along with the other class scope ui objects right under your class declaration with the 'Protected WithEvents' declaration.

Try it.

If that doesn't work, then try initializing the object in the page's init event (page_init).

Try it again.
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top