472,958 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 7274
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.