473,404 Members | 2,137 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,404 software developers and data experts.

CheckBox and Datagrid

Hi,

I need some help with automatically generated checkbox in my datagrid,
i'm searching everywhere and can't find a way to do this.

In my datagrid i will always have more than one line, with one checkbox
on each line (each line is an option for our costumers).
But i want to :

- have autopostback set to true only on the first (or any other,
selected before the databind) checkbox
- when the form is sudmited, check wich checkbox is checked, so i can
view what the customers have selected, but they have all the same ID,
because if i try to assign a different ID to each one, like this :
<asp:CheckBox Runat=server ID=<%# container.dataitem("serviceno")%>
AutoPostBack=True/> i receive this error : '<%#
container.dataitem("serviceno")%>' is not a valid identifier.

Did someone have any idea for this ?

Thank you.

Nov 18 '05 #1
1 1207
call all the checkboxes the same ID

then, when you want to find out their values, do this

dim tempcheckbox as checkbox

for counter = 0 to MyDataGrid.Items.Count - 1
tempcheckbox =
CType(Mydatagrid.Items(counter).FindControl("check boxname"), CheckBox)

if tempcheckox.checked then
'do whatever.
end if
next

you might have to use mydatagrid.items(counter).cells(x).FindControl instead
(where x is the index of the cell with the checkbox), i'm not sure.

R

"Andre" <lo*****@cablevision.qc.ca> wrote in message
news:OT**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need some help with automatically generated checkbox in my datagrid,
i'm searching everywhere and can't find a way to do this.

In my datagrid i will always have more than one line, with one checkbox on each line (each line is an option for our costumers).
But i want to :

- have autopostback set to true only on the first (or any other,
selected before the databind) checkbox
- when the form is sudmited, check wich checkbox is checked, so i can
view what the customers have selected, but they have all the same ID,
because if i try to assign a different ID to each one, like this :
<asp:CheckBox Runat=server ID=<%# container.dataitem("serviceno")%>
AutoPostBack=True/> i receive this error : '<%#
container.dataitem("serviceno")%>' is not a valid identifier.

Did someone have any idea for this ?

Thank you.

Nov 18 '05 #2

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

Similar topics

0
by: Just D | last post by:
Hi All, Does anybody know how to write the following code? I have a database table with a few columns including: ID , "Task" , ForceRun . I need to show the DataGrid on the ASPX page with...
2
by: Sebi | last post by:
Hello all is it possible to add a checkbox in a DataGrid for Boolean Data? Thanks in advance
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...
1
by: iforsyth | last post by:
Have a paging datagrid with a checkbox control in column(0). ViewState is enabled. I check the checkbox in first row of the grid on a page and then the program hits this event: Private Sub...
0
by: mehul | last post by:
CheckBox template always evaluate to False even if checked in a DataGrid hosted inside a TabStrip in ASP.NET Hi, I am trying to develop an ASP.NET application. I am using TabStrip (which is...
7
by: Lars Netzel | last post by:
If I put a checkbox in a datagrid (ASP.NET) and set the Autopostback to true I can catch OnChange event on checkbox but how do I then catch what DataGridItemIndex is? Can I use some Event in the...
10
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...
2
by: Adam Knight | last post by:
Hi all, I have a datagrid with a checkbox in one column. The checkbox is set to autopostback and calls a method named UpdateMailSubscribers. The first click on the checkbox cause the page to...
9
by: Rekha | last post by:
The data is filled in datagrid. I want to know how to add a checkbox column in datagrid? In the runtime, checkbox is checked then instead of checkbox value the (caseID )column value is retained....
3
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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.