Solved

Datagridview select all rows selected with checkbox

Posted on 2009-07-02
2
533 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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now