473,804 Members | 3,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically add a asp:checkbox in a table.

UJ
I have a table that I need to manually generate based on stuff in the
database. I build the actual table string and stuff it into an asp:panel. So
far it works fine. I'm now trying to add a checkbox to each cell so that
whether it's selected or not.

Problem is, I set the code in the cell during page_load but if I look at the
actual HTML, it says <asp:checkbox ..... whereas everything that is
not dynamic is normal html. So apparently the code is not getting translated
into html.

Here's what I'm actually trying to do: we have pictures we put on our
website. We one a day and remove one a day. The customer would like to see a
'calendar' of pictures and select/deselect the ones they receive. This means
that if it's a Tuesday, they would like to see from Tuesday forward. Monday
would be blank. If it's Thursday, Sunday, Monday, Tuesday and Wednesday
would be blank. Like I said I manually created the table and it works (it's
pretty wild code though) but maybe somebody has a better suggestion on doing
it. The only thing I can think of is to retrieve the data, then prepad the
days so they always start with Sunday and hide everything before this day of
the week.

Anybody got any suggestions?

TIA - Jeff.
May 1 '06 #1
1 6811
> Problem is, I set the code in the cell during page_load but if I look at
the actual HTML, it says <asp:checkbox ..... whereas everything that
is not dynamic is normal html. So apparently the code is not getting
translated into html.


How are you adding to the panel? Creating dynamic controls can be a bit
tricky. One thing to keep in mind is that you have to recreate the control
array on every postback; otherwise ASP.NET won't restore the objects (you
won't see them). You also need to do this to keep the viewstate untainted.

Here's an example (not tested)

protected void Page_Init(objec t sender, EventArgs e)
{
for (int i = 0; i < 20; i++)
{
CheckBox box = new CheckBox();
box.ID = "myBox" + i.ToString();
box.Text = "label " + i.ToString();

Panel1.Controls .Add(box);
}
}

May 1 '06 #2

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

Similar topics

1
2160
by: Paul | last post by:
HI I have a asp page which dynamically creates a table with 28 rows, 3 columns. Column 1 contains a label, column 2 contains a graphic, column 3 needs to contain a checkbox. I have no problems with column 1 & 2, but column 3 gives me this error :- Control 'CHECKBOX1' of type 'CheckBox' must be placed inside a form tag with runat=server. Any ideas?
9
2299
by: Harry | last post by:
Dear All, First of all, i have a database and i have to select the data in a table. In the web form, i have a checkbox in each rows. So that the use can select the row. initally, i am thinking to use the dataset and databind the datagrid to show the form.
2
6641
by: Maziar Aflatoun | last post by:
Hi everyone, I am reading and displaying data rows from my database where the first column contains the Status checkbox. I like to enable my users to change the status of individual rows by checking and unchecking the checkbox column. I like to update the status in the database for the column where the status was changed. This is what I'm doing so far
6
10005
by: anirban.anirbanju | last post by:
hi there, i've some serious problem to add rows dynamically in a table. my table contains 5 cell. | check | from_value | to_value | color_text | color_value | --------------------------------------------------------------------------------- | | | | | | | | | | |
2
14656
by: UJ | last post by:
Is there a way with a asp:checkbox to run a JavaScript to display/hide text/input on the screen without doing a postback? I also need to be able to access the stuff at the server so I need to have run=server with it. TIA - Jeff.
4
1852
by: UJ | last post by:
I've got an page that dynamically generates a table (don't ask!) that includes in each cell a checkbox. I can get the checkbox create but I can't figure out how to get an event tied to it so that when the person changes the value, I get notification. Also - there appears to be no runat property when I create the checkbox. Is this automatically true? TIA - Jeff.
1
2880
by: Bill44077 | last post by:
I am dynamically adding a checkbox in a gridview and I find there are several things that I cannot figure out how to address. 1. The width of the checkbox column is very wide. I've tried adding properties and Item Style to the column but it has no effect. Is there someway to size this column to be smaller? I removed the CssClass property and it had no effect on the size as well. 2. The gridview is sortable using javascript. Is there...
4
4068
by: Mike Haberfellner | last post by:
....hi everyone, ....i posted this allready, but my newsreader doesn't display it to me - so i'm sorry if it's posted twice... hi again, sorry for not clearly writing what i really need :) if i have the following in the aspx file
1
1590
by: mike Jan | last post by:
In the Page_Load, I dynamically assign a string which contians asp:checkbox to a InnerHtml. But the checkbox does not display on the page after the page loaded.
0
9585
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10586
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...
0
10338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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
9161
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...
0
6856
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
5525
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...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3823
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.