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

Checkbox control issue

I'm having problem with code that I originally obtained from:
http://support.microsoft.com/default.aspx?scid=kb;...

This code is supposed to loop through datagrid rows and determine which rows
have cell18, a checkbox, selected. When I run this code it is erroring out
at line: "DataGrid1.DataKeys(DemoGridItem.ItemIndex)". After placing a watch
on the code it shows that .ItemIndex has a constant value of 0. What is
going wrong here and how can I fix it? Thanks.

---------------------------------------------------------
Private Sub GetSelections_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles getSelections.Click
Dim rowCount As Integer = 0
Dim gridSelections As StringBuilder = New StringBuilder

'Loop through each DataGridItem, and determine which CheckBox
controls have been selected.
Dim DemoGridItem As DataGridItem
For Each DemoGridItem In DataGrid1.Items

Dim myCheckbox As CheckBox =
CType(DemoGridItem.Cells(18).Controls(1), CheckBox)
If myCheckbox.Checked = True Then
rowCount += 1
gridSelections.AppendFormat("The checkbox for {0} was
selected<br>", DataGrid1.DataKeys(DemoGridItem.ItemIndex).ToStrin g())
End If
Next
gridSelections.Append("<hr>")
gridSelections.AppendFormat("Total number selected is: {0}<br>",
rowCount.ToString())
ResultsInfo.Text = gridSelections.ToString()

End Sub
---------------------------------------------------------
Jul 21 '05 #1
0 987

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

Similar topics

4
by: Bill | last post by:
I have a catalog of books which need to be categorized into different groups. Some of the books can be listed under more than one category. I'm creating a page where I can assign a group of books...
0
by: Steven | last post by:
Hi, I'm creating a custom checkbox list control which will take 2 arraylists as input. (One will contain Names and other will contain 0s and 1s. 0 - uncheck 1- check). I'm able to create the...
0
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...
3
by: simon | last post by:
I have dataRepeater with itemtemlate: <ItemTemplate> <tr> <td><%# DataBinder.Eval(Container.DataItem,"adv_name") %></td> <td><%# DataBinder.Eval(Container.DataItem,"adv_start") %></td> <td><%#...
9
by: Craig Andrews | last post by:
Hello, How do I access HTML CheckBoxs in the codebehind section of an ASP.NET program? In the old Interdev days one would: For i = 1 to Request.Form("CheckBox").Count if...
2
by: Javier | last post by:
Hi Everyone, I have a dynamic checkbox in a datagrid that uses the ITemplate interface and has the checkchanged event wired up. When the checkbox is checked, the event event handler that...
4
by: | last post by:
I have a checkbox on a web page. When it is checked, I want a Table to appear (or disappear when the checkbox is cleared)... I was hoping to use client side code for this, so I created a short...
8
by: Alan Silver | last post by:
Hello, I have a repeater that has code like this... <ItemTemplate> <asp:CheckBox ID="chkDelete" Text="" RunAt="server"/> .... other stuff goes here </ItemTemplate> There is a button below...
4
by: Matrixreloadedth | last post by:
How to change disable color of Checkbox??? I have a checkbox with forecolor in red but when i disable by set Enable properties to false forecolor is changed to gray color but i don't want it. how...
6
by: Rick | last post by:
Hi group, I'm trying to inherit from the windows checkbox control. This is no problem. My goal is to add a property that is based on an enum. When I have an enum declared within the class, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...
0
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,...
0
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...

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.