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

Home Posts Topics Members FAQ

ASP.Net Checkbox Problem

Hello,

I am fairly familiar with Web Development with .Net, but i have come
across a problem that is giving me some trouble......

I want to have a list of checkboxes where 1) the labels come from one
table and 2) each box is checked or unchecked according to a different
table.

I have figured out a way to load the checkboxes by using a DataList. I
then put a single Checkbox in the ItemTemplate and bound the text and
checked properties.

My problem is that im not sure how to go about updating the table that
holds the Checked values. I dont know how to access each checkbox in
the DataList.

If someone has a better solution, i am completely open to
suggestions.... .Please note i am developing in C#
Thanks,
Matt

Feb 15 '07 #1
2 1631
On Feb 15, 2:32 am, mschmid...@gmai l.com wrote:
Hello,

I am fairly familiar with Web Development with .Net, but i have come
across a problem that is giving me some trouble......

I want to have a list of checkboxes where 1) the labels come from one
table and 2) each box is checked or unchecked according to a different
table.

I have figured out a way to load the checkboxes by using a DataList. I
then put a single Checkbox in the ItemTemplate and bound the text and
checked properties.

My problem is that im not sure how to go about updating the table that
holds the Checked values. I dont know how to access each checkbox in
the DataList.

If someone has a better solution, i am completely open to
suggestions.... .Please note i am developing in C#
while( myDataReader.re ad() )
{
CheckBox x = new CheckBox();
x.Text = myDataReader["name"].ToString();
x.Checked = (bool)myDataRea der["checked"];
Page.Controls.A dd(x);
}

Then further up in your code populate your DataReader object according
to some inner join... e.g.:
"select * from x, y where x.someIdPrefera bleA_ForreignKe y =
y.someOtherIdPr eferableA_Prima ryKey"

....

..t

--
http://ajaxwidgets.com
Free ASP.NET Ajax Widgets NOW!

Feb 15 '07 #2
Accessing the CheckBoxes in dataList can be accomplished with

foreach(DataLis tItem litem in DataList1.Items )
{
CheckBox cb = (CheckBox)litem .FindControl("C heckBox1");
//Process the CB here
}
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

<ms********@gma il.comwrote in message
news:11******** **************@ a75g2000cwd.goo glegroups.com.. .
Hello,

I am fairly familiar with Web Development with .Net, but i have come
across a problem that is giving me some trouble......

I want to have a list of checkboxes where 1) the labels come from one
table and 2) each box is checked or unchecked according to a different
table.

I have figured out a way to load the checkboxes by using a DataList. I
then put a single Checkbox in the ItemTemplate and bound the text and
checked properties.

My problem is that im not sure how to go about updating the table that
holds the Checked values. I dont know how to access each checkbox in
the DataList.

If someone has a better solution, i am completely open to
suggestions.... .Please note i am developing in C#
Thanks,
Matt
Feb 15 '07 #3

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

Similar topics

1
6041
by: Claire | last post by:
Hello, I am having a problem in my struts application with the checkboxes in my form. I have an array of checkboxes, some of which may be already selected when the form loads. My problem is when the user then deselects one or more of these checkboxes and submits the form - they're being submitted as if they were still checked, when the user has infact deselected them. I've heard that this is a common problem, but I don't seem to be...
2
2339
by: Tomas Vera | last post by:
Hello All, I'm having problems creating a page with dynamic checkboxes in a WebApp. In my app, I need to query a database, then (based on results) add checkboxes to my form and set their "Checked" state. Since the controls are dynamically created, I'm using the OnInit event to create the checkboxes and set the "Checked" state from the DB. Next, I want to capture the postback event (AutoPostBack=true) and update my database based on...
0
2408
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a CheckBox Programmatically" in my code. I have changed it to use a OLDDB.DBReader to populate the datagrid and for the databinding. It works perfectly - also when using the edit-mode in the datagrid.
10
2449
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox control in a datagrid? Now I have a Select column but the problem is that the user needs to select more than one record and send them all to print, instead of being one by one like is now with the Select column. Another question, is it possible to...
4
3952
by: SJ | last post by:
Hi all, I have come across a weird problem when attempting to automatically set the focus in a vb.net form to a checkbox control... In my form I have (on a tab page in a tab control) several textboxes and a checkbox. The behaviour I want from my app is as follows:- When the textbox (which is prior in tab order to the tab control) has been filled with a certain length of text by the user, the focus is
1
4023
by: spolsky | last post by:
try the the following code with Opera 9.01 (Windows). when clicked slightly faster than normal clicking, the toggler checkbox and other checkboxes displays differently although event method works fine to update the checkboxes. there is not any problem with IE 6 or FireFox 1.5. also, i used the double click event method to see if its the source but that does not help even. Opera 9.01 seems to be slow at updating checkboxes visually. am i...
9
1798
by: morellik | last post by:
Dear all, I have a program that creates dinamically a web page. In the page I have the following function to check how many checkbox are checked. function tarInfo(info) { var i=0; var c=0; var l=document.forms.selected_files.length; alert(l);
0
4105
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me with my problems. Now for my new little problem,I had a problem posting the values from checkbox fields to a database and thats the obstacle I overcame. Now the second part is my new problem is that I want that the next time that page loads for...
3
2915
by: Mahathi | last post by:
Hi I have a small problem in maintaining the state of a check box. Please do me a favour by telling me the procedure how to do that. My requirement is that "I have to map some roles with that of the users of the project. I have used checkboxes for selecting the roles that a particular user has. For example, an adminstrator has all roles in an organisation. Similarly an Employee has limited roles. Here let us take administrator...
4
4441
by: Charlotte | last post by:
Hi, I have a problem with a ASP-script, can somewone help me ? here is what I've got: mypage.asp : .... code ... <%
0
9706
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
9582
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
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9157
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
6854
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...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.