473,413 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

dynamically generate checkboxlists (ASP .net 2.0 w/ C#)

I'm building an internal site which will allow for extremely
customizable queries to be run against our SQL Server (2000) DB. The
page is done in ASP .net 2.0, with C# code behind.
The initial page has a checkboxlist which is generated from a query
which returns all the user tables in our database. This is
checkboxlistTables. For each table selected in this list I want to
dynamically generate a new checkboxlist in a (HTML) table on the page.
These new check lists query the database and display a checkbox for
each column in the associated table.

The way I'm doing it now is, I've simply created the 12 or 13
checkboxlists (one for each table in our db) which query
INFORMATION_SCHEMA.Columns to populate their lists. I simply make these
listboxes visible when the appropriate check box is checked in
checkboxlistTables. As you can imagine this entails a lot of redundant
code, and will 'cause some problems down the road as tables are
added/deleted. What I want to do is create an array (or something
similar) of checkboxlists, which are generated and populated on the fly
as needed. This is where I am stuck, as I've never done something like
this, and am not sure how to proceed.

At the moment I use something along the lines of:
for (int i = 0; i < CheckBoxList0.Items.Count; i++)

for each checkboxlist (CheckBoxList0 - CheckBoxList11) to see which
columns from which tables needed to be included in my query. I'd like
to be able to do something like:
for (int i = 0; i < CheckBoxList[x].Items.Count;i++) inside of a larger
loop which cycles through all of the generated listboxes. Is this
possible? Any solutions/suggestions on generating these listboxes and
cycling through them?

Thanks in advance,
KrB

Apr 11 '06 #1
1 2820
This is very possible and I've done something similar for
customer-defined properties. A couple of notes:

1. I used an asp:placeholder control as the 'root' of the custom
control list.
2. you'll have to build your controls every time - not just the first
time you hit the page. Otherwise the controls don't exist and asp.net
won't know what to do with the form collection.
3. You can then call placeholder.FindControl() for each of your custom
controls to get its value.

Hope that helps!

-Brian

Apr 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: mscir | last post by:
Date: Thu, 08 Jul 2004 17:02:27 -0700 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <10ero4l3kp2qa65@corp.supernews.com> Reply-To: mscir@usa.com User-Agent: Mozilla/5.0...
7
by: Rathtap | last post by:
I want to write a C# application (lets call it Generator) that will receive an argument(patient account number) and dynamically generate a series of linked HTML files (claim information, payments,...
2
by: grawsha2000 | last post by:
Hello, How can I add a table to asp.net page dynamically with Code Behind style. I still can't find a way of doing it. This really causes me a big problem when I deal with records from...
3
by: Dotnet Gruven | last post by:
I've built a WebForm with a Table added dynamically in Page_Load when IsPostBack is false. The table includes a couple of TextBoxes, RadioButtonLists and CheckboxLists. On postback, those...
0
by: KBuser | last post by:
I'm building an internal site which will allow for extremely customizable queries to be run against our SQL Server (2000) DB. The page is done in ASP .net 2.0, with C# code behind. The initial...
9
by: netasp | last post by:
hi all, how can I populate one aspx form when page is loading based on page ID? for example: loading page A (to search for VB code) would display labels and texboxes, dropdown lists all related...
1
by: sheenaa | last post by:
Hello friends, I m using ASP.NET with C# 2005 and SQL SERVER 2005 for the ASP.Net Website. I m using sqldatasource to connect and retrieve the data from database and then it displays the data...
1
by: stepby | last post by:
Generate the ASP code dynamically Hi All, I would like to ask how to generate the ASP code dynamically? The case is that there are several textbox and the number of textbox is controlled by...
1
by: terminul | last post by:
Hi I have a datalist which loops through the categories and within the datalist I have a CheckBoxList which are bound on the DataList's OnItemDataBound. The only problem I have is retrieving...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.