Solved

Datagridview select all rows selected with checkbox

Posted on 2009-07-02
2
546 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
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…

733 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