473,397 Members | 1,949 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.

Using Checkboxes Within the DataGrid Control to Select Records

I have an ASP.NET custom control, which contains a DataGrid with
checkboxes. I am trying to figure out how to retrieve the selected
records, based on the checkbox's checked state. I want to send the
results to a list control on the containing .ASPX page.

Here is what I have in my code behind (C#):

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication5.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1"
name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<div style="OVERFLOW: auto; WIDTH: 100%; HEIGHT: 200px">
<asp:DataGrid id="DataGrid1" runat="server" style="Z-INDEX: 102;
LEFT: 24px; POSITION: absolute; TOP: 32px" Height="120px">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<INPUT type="checkbox">
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid></div>
</form>
</body>
</HTML>

I looked for examples via Google, Yahoo, etc. but couldn't find much in
the way of C#. Any help would be appreciated.

Nov 19 '05 #1
5 7297
sianan,

I have example code for doing exactly this on my website.
http://www.aboutfortunate.com?page=codelibrary

Use the textbox there to search for "checkbox in datagrid" and you'll have
the example code.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"sianan" <sm*********@tds.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have an ASP.NET custom control, which contains a DataGrid with
checkboxes. I am trying to figure out how to retrieve the selected
records, based on the checkbox's checked state. I want to send the
results to a list control on the containing .ASPX page.

Here is what I have in my code behind (C#):

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication5.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1"
name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<div style="OVERFLOW: auto; WIDTH: 100%; HEIGHT: 200px">
<asp:DataGrid id="DataGrid1" runat="server" style="Z-INDEX: 102;
LEFT: 24px; POSITION: absolute; TOP: 32px" Height="120px">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<INPUT type="checkbox">
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid></div>
</form>
</body>
</HTML>

I looked for examples via Google, Yahoo, etc. but couldn't find much in
the way of C#. Any help would be appreciated.

Nov 19 '05 #2
You'll have to loop through the grid rows, using a FindControl() to grab the
checkbox, (you'll have to give the checkbox and id). At that point you can
check the true/false of the checked property.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"sianan" wrote:
I have an ASP.NET custom control, which contains a DataGrid with
checkboxes. I am trying to figure out how to retrieve the selected
records, based on the checkbox's checked state. I want to send the
results to a list control on the containing .ASPX page.

Here is what I have in my code behind (C#):

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication5.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1"
name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<div style="OVERFLOW: auto; WIDTH: 100%; HEIGHT: 200px">
<asp:DataGrid id="DataGrid1" runat="server" style="Z-INDEX: 102;
LEFT: 24px; POSITION: absolute; TOP: 32px" Height="120px">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<INPUT type="checkbox">
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid></div>
</form>
</body>
</HTML>

I looked for examples via Google, Yahoo, etc. but couldn't find much in
the way of C#. Any help would be appreciated.

Nov 19 '05 #3
Thank you for the response!

I did indeed find the code, the problem is that it is in VB.NET. For
some reason, I wasn't able to convert it into C#. Still trying.....

Nov 19 '05 #4
Thanks for the response. I appreciate your help.

Still trying to get this to work with C#.

Nov 19 '05 #5
Sianan,

I'd be happy to help you convert it. Send me what you have so far if you'd
like (less typing for me that way) or tell me where you're hung up.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"sianan" <sm*********@tds.net> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Thank you for the response!

I did indeed find the code, the problem is that it is in VB.NET. For
some reason, I wasn't able to convert it into C#. Still trying.....

Nov 19 '05 #6

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

Similar topics

2
by: Steve B | last post by:
I am trying to design a Call Log Detail form that will allow users, in a multi-user environment, to select various data/records, not necessarily in sequential order, from a subform that will, when...
2
by: john | last post by:
I posted this question to comp.lang.javascript but didn't get a response, so I'll try here. I am using ASP.NET and I have a datagrid. One of the columns in my grid is all checkboxes. When the...
2
by: Craig G | last post by:
i have a datagrid, i use the footer to allow the user to add records so the user fills in the textboxes/combo's and clicks Add, this populates properties in a class, a function within the class...
2
by: Mortar | last post by:
i have a datagrid with 2 columns. the 1st column contains an id which will be used by the database for the selected checkbox records. the 2nd column is a template column containing a server...
0
by: Mike Draper | last post by:
The goal of this section of the app is to have a datagrid that displays rows to the user who will then select which rows he wishes to continue the process with. The Grid containing all choices...
0
by: Patrick.O.Ige | last post by:
I have a datagrid with checkboxes.. When a user clicks one check box and clicks the delete button it deletes that ROw. There another situation when a user clicks multiple rows so i had to loop...
6
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
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.