473,783 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
checkboxlistTab les. 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_SCH EMA.Columns to populate their lists. I simply make these
listboxes visible when the appropriate check box is checked in
checkboxlistTab les. 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.I tems.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 2838
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.Fin dControl() 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
2304
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 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@supernews.com
7
25366
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, denials etc) by querying a database based on the argument. This Generator can be called from an aspx web page, a Cold Fusion page as well as from a windows application. 1. Does this C# app have to be a console application to receive arguments?...
2
1640
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 database as I need to construct the table dynamically.
3
2544
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 controls are not present nor their valves in Request.Form.AllKeys.
0
1489
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 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...
9
7042
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 to VB, plus the address bar would show something like this: www.somethinghere?id=3 and if you change number 3 from the address bar to (for example) 34 or 71 you would get different page with the same formatting like I.e: www.somethinghere?id=34...
1
3086
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 in the gridview on the button click event.I have created the stored procedure for insert and select query. Now in my application i have used checkboxlist where there can be multiple selection for the hobbies. I want to know how can i store the...
1
1476
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 user <form name ="test" action="test.asp"> <input type="text" id="txt1" name="title1">
1
7940
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 the values that have been checked when the user submits the form. This code works as far as presentation goes but I can't seem to retrieve the checked values in the various checkboxlists that have been generated on the datalist's OnItemDataBound ...
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10083
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.