473,387 Members | 1,520 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.

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 986

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
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...

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.