473,770 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem reseting CheckBoxList when not checked.

I have CheckboxList Databinded below and that works fine and i can get the
selected values after PostBack.
But what i have noticed is that when you select a checkbox i.e lets say 3 of
them and later unselect them the last one u unselect remains printed out on
the screen.
How can i reset Checkboxlists back to NULL.
I need to do this becos i'm passing the values to a QueryString and if the
unselect and remains in the queryString its a problem.
Any ideas?
<asp:checkboxli st id="chkList" AutoPostBack="T rue" Runat="server"
DataValueField= "ProductFeature ID" DataTextField=" Feature"
OnSelectedIndex Changed="Check_ Clicked"></asp:checkboxlis t></td>

Sub Check_Clicked(B yVal sender As Object, ByVal e As EventArgs)
'print.Text = "Selected Item(s):<br><br >"
Dim i As Integer
Dim a As String

Dim P As String = ""
For i = 0 To chkList.Items.C ount - 1

If chkList.Items(i ).Selected Then
P &= "," & chkList.Items(i ).Value
print.Text = P
End If
Next
End Sub
Nov 19 '05 #1
1 1488
Well fixed it by doing:-
print.Text =""

"Patrick.O. Ige" wrote:
I have CheckboxList Databinded below and that works fine and i can get the
selected values after PostBack.
But what i have noticed is that when you select a checkbox i.e lets say 3 of
them and later unselect them the last one u unselect remains printed out on
the screen.
How can i reset Checkboxlists back to NULL.
I need to do this becos i'm passing the values to a QueryString and if the
unselect and remains in the queryString its a problem.
Any ideas?
<asp:checkboxli st id="chkList" AutoPostBack="T rue" Runat="server"
DataValueField= "ProductFeature ID" DataTextField=" Feature"
OnSelectedIndex Changed="Check_ Clicked"></asp:checkboxlis t></td>

Sub Check_Clicked(B yVal sender As Object, ByVal e As EventArgs)
Dim i As Integer
Dim a As String

Dim P As String = ""
For i = 0 To chkList.Items.C ount - 1

If chkList.Items(i ).Selected Then
P &= "," & chkList.Items(i ).Value
print.Text = P
End If
Next
End Sub

Nov 19 '05 #2

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

Similar topics

0
7949
by: Bryce Budd | last post by:
Hello All, I've been a taker of information from newsgroups for a long time and thought I'd finally make a contribution back to the community whose supported me when I've needed it. After all before commercialization took over that was the beauty of the Internet! I've create a checkboxlist validator control...something MS should have done originally in my opinion, but nonetheless here it is. It's a C# control, sort of IE specific. ...
3
2922
by: I am Sam | last post by:
I keep getting the following error message when I try to iterate through a CheckBoxList control: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance...
2
5237
by: Patrick.O.Ige | last post by:
I have some boolean value(1 or 0 ) in a table and i want a databinded CheckBoxList to present the selected values on the page.. With CheckBox i know i can se the Checked property like so :- <asp:CheckBox id="chk" checked=<% Databind.Eval("This returns 1 or 0")%> runat="server"%> Any help how i can do it using CheckBoxList?
2
1324
by: Patrick.O.Ige | last post by:
I have a Checkboxlist that is databinded and i want to pass it a boolean value from a table because i want to display the checked values if its TRUE. When Databinding my checkboxlist i'm not passing the column name with the boolean values to the DataValueField which is the column "checked" but instead i want to loop through the checkboxlist and pass the Boolean values to it like so below But it seems not to work.!!! Any ideas??
1
1206
by: Lynn | last post by:
Hello, I have a page that allows the person to select multiple items from a checkboxlist. The checkboxlist is being populated from a table in the database. The user's selections are sent to the database as a comma separated list (ex. 17, 22, 35). I also have a page that allows the user to edit existing records. I am unsure of how to build the checkboxlist on the edit page and have the various checkboxes checked based on what is in the...
2
407
by: jase_rw | last post by:
Hi There, Having trouble with a CheckBoxList in VB.NET. I've a CheckBoxList on a webform. I read some data from a database and try and check the appropriate boxes based on the data. Unfortunately, the CheckBoxList seems to behave like a RadioButtonList and only leaves the last item checked. I've even tried just to hard code 2 boxes being checked and that just
14
7970
by: Satheesh Babu B | last post by:
hai.. am having a checkboxlist..now how do i get the value of the checkbox that is checked in checkboxlist using javascript? Thanks in advance.... Regards,
2
5524
by: Stimp | last post by:
I have a checkboxlist (chkMyList) which is created from a (name, value) pair from a database table. I have a read-only textbox which will be used to hold a total of all the numerical values of each checkbox that is checked, and this value will change dynamically via javascript when a box is ticked or unticked. e.g. <script language="javascript"> function GetCost() {
0
9591
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
9425
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
10228
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
10057
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...
0
9869
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
8883
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
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
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.