Solved

Datagridview select all rows selected with checkbox

Posted on 2009-07-02
2
537 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 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