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

Clicking Anywhere in DataGrid Row to Check CheckBox

Is this possible?

I need to create a multi-select DataGrid, and I cannot use CheckBoxes.
I want the selected rows to appear highlighted. One possible
work-around that occurred to me was to devise my code in such a way as
to allow the user to click anywhere in a DataGrid row, which would
check the CheckBox for that row. Similarly, clicking again in the same
row would un-check the CheckBox. The CheckBoxes in question would be
invisible, and the selected (checked) rows would appear highlighted.
This should give me the appearance I'm looking for (assuming that it
works).

Is this possible? My efforts so far have been unsuccessful.

Is there any chance that someone could provide me with a code snippet
or two, showing how this can be done (if it can be done)?
Thanks!!!

Nov 28 '05 #1
1 2232
Handle ItemDataBound event:

private void dgSelection_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
// provide client-side selection a datagrid row upon clicking
any place on the row.
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
{
return;
}
e.Item.Attributes["onclick"] = "onRowClick(this)";
}

Javascript function onRowClick(row) takes a refrence to the clicked row as a
parameter, You can set the row's visual attributes in javascript.

Eliyahu

".NETn00b" <re**********@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Is this possible?

I need to create a multi-select DataGrid, and I cannot use CheckBoxes.
I want the selected rows to appear highlighted. One possible
work-around that occurred to me was to devise my code in such a way as
to allow the user to click anywhere in a DataGrid row, which would
check the CheckBox for that row. Similarly, clicking again in the same
row would un-check the CheckBox. The CheckBoxes in question would be
invisible, and the selected (checked) rows would appear highlighted.
This should give me the appearance I'm looking for (assuming that it
works).

Is this possible? My efforts so far have been unsuccessful.

Is there any chance that someone could provide me with a code snippet
or two, showing how this can be done (if it can be done)?
Thanks!!!

Nov 28 '05 #2

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

Similar topics

5
by: Jean Carlo | last post by:
Hello guys I`m developing a windows form that contain one Datagrid. In this datagrid I insert a checkBox Column. I need to get all rows where checkbox is checked by user. How do I get this...
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...
1
by: Machi | last post by:
Let say i select rows of records with 4 columns from Database and want to display the data in DataGrid (ASP.NEt Server Control) with one column which must be displayed in CheckBox layout. For the...
6
by: jiangyh | last post by:
hi there: I have a datagrid in my web form that contain a templet column.And in this templet column have a checkbox web control.I will get the checkbox state in my serverside. My question is...
1
by: rodchar | last post by:
hey all, is the following even possible? i have a datagrid with checkboxes on each row, when a user clicks on the checkbox i'd like to populate one of the fields in the grid with the current...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
0
by: upendra | last post by:
Hi, I am B.V.Ramesh Babu.I am working as software programmer using .net.We are using asp.net1.1 with C#.net as coding.I hope that i will get the required support from you. Here is my requirement....
7
by: rn5a | last post by:
The first column of a DataGrid has a CheckBox for all the rows. I want that when users check a CheckBox, the BackColor of that entire row in the DataGrid should change to a different color. To...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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,...

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.