473,652 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2241
Handle ItemDataBound event:

private void dgSelection_Ite mDataBound(obje ct sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{
// provide client-side selection a datagrid row upon clicking
any place on the row.
ListItemType itemType = e.Item.ItemType ;
if ((itemType == ListItemType.Pa ger) ||
(itemType == ListItemType.He ader) ||
(itemType == ListItemType.Fo oter))
{
return;
}
e.Item.Attribut es["onclick"] = "onRowClick(thi s)";
}

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**********@y ahoo.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.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
2631
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 rows ? I can´t use the DataSource of Datagrid because I don´t have a Column source for checkBox in my DataSource. Is there any method in datagrid to loop in datagrid rows ?
0
2397
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 CheckBox Programmatically" in my code. I have changed it to use a OLDDB.DBReader to populate the datagrid and for the databinding. It works perfectly - also when using the edit-mode in the datagrid.
1
4151
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 dgRegGrid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgRegGrid.PageIndexChanged I then do a loop to check the checkbox state.
1
663
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 column (which contains checkbox), when i click the CheckBox in the Header of DataGrid, all the rows (for column which contains Checkboxes) must be checked. When i uncheck the checkbox in Header of DataGrid, all the rows of that column must be unchecked,...
6
1357
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 which server-side event I will add to my codebehind when I change the checkbox state of the DataGrid templet column.
1
1223
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 date. how would i do that?
1
4227
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 the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
0
1472
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. I am using datagrid control.In that data grid I put checkboxes in both item templete and in Header templete.My requirement is is if i check any checkbox in itemtemplete and click delete button those records will be deleted.In another way I ...
7
2505
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 implement this, if I am not mistaken, I HAVE TO post the Form first i.e. set the AutoPostBack property of the CheckBox to True. Without posting the Form, I don't think the BackColor of the checked row can be changed using ASP.NET, isn't it? Of...
0
8370
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8283
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8704
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6160
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2707
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.