473,387 Members | 1,611 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,387 software developers and data experts.

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 6793
> 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(object 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
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...
9
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...
2
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...
6
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
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...
4
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...
1
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...
4
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 :) ...
1
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.