Solved

Datagridview select all rows selected with checkbox

Posted on 2009-07-02
2
542 Views
Last Modified: 2012-05-07
Need make a sql query with  selected rows in a datagridview. The rows are selected with a checkbox. How can do.
0
Comment
Question by:rflorencio
  • 2
2 Comments
 
LVL 14

Assisted Solution

by:shahprabal
shahprabal earned 500 total points
ID: 24763306
check out :
http://www.c-sharpcorner.com/UploadFile/ciennie/DatagridHeaderCheckbox12302005061806AM/DatagridHeaderCheckbox.aspx?ArticleID=9a1c67b0-56bf-48aa-a4df-79899a5b45e9


<script type="text/javascript">
function SelectAll(CheckBoxControl) 
{
if (CheckBoxControl.checked == true) 
{
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgdept_details') > -1)) 
{
document.forms[0].elements[i].checked = true;
}
}
} 
else 
{
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgdept_details') > -1)) 
{
document.forms[0].elements[i].checked = false;
}
}
}
}
</script>
 
<HeaderTemplate>
<input type="CheckBox" name="SelectAllCheckBox" onclick="SelectAll(this)">
</HeaderTemplate>

Open in new window

0
 
LVL 14

Accepted Solution

by:
shahprabal earned 500 total points
ID: 24763332
in the above eg you need to replace 'dgdept_details' with the name of the checkbox control in your grid.
if you don't mind doing it server side then check out :
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_21927434.html?sfQueryTermInfo=1+all+checkbox+datagridview+row+select
and this has a better client side example :
http://aspnet.4guysfromrolla.com/articles/052406-1.aspx
 
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question