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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a checkboxlist control to formview insert template

Status
Not open for further replies.

kindicheema

Programmer
Jun 21, 2006
6
GB
Hi
Im new to ASP.Net 2.0, so this may be a very simple question, i have created a formview that has insert, edit, and delete templates, and i have used sql stored procedures to bind to the templates, which all works ok.
Ive added checkboxlist control on the insert form (which gets the value and text from another table in the database )so that a user can do multiple selection. The store proc handles adding the data to the database, getting the id and then taking a string of the multiple selections and adding that data against the id into a normalised table.

The problem is that the form does not recogonise the checkboxlist and thinks it is undeclared in the code behind. If you place the checkboxlist just outside the form and run the page the checkboxlist does not appear.

Unsure what to do next, please help!
 
is that the form does not recogonise the checkboxlist and thinks it is undeclared in the code behind
What exactly does this mean? Are you getting an error(s). What code do you have so far?
 
the checkboxlist control is contained with the FormView Insert Template. you're trying to access the control from the Page. The page has no knowledge of the FormView's contents. you need to use the Contorls.Find("name of control") property to get the instance of the checkboxlist from the formview and cast it.
sample
Code:
CheckBoxList cbl = MyFormView.Controls.Find("MyCheckBoxList") as CheckBoxList;
if(cbl != null)
{
   //use cbl
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top