Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Datagridview select all rows selected with checkbox

Posted on 2009-07-02
2
Medium Priority
?
558 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 2000 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

971 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