Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...select all checkbox on page of a gridselect all checkbox on page of a grid
Previous
 
Next
New Post
4/12/2008 4:48 AM
 

Hello,,

 

I know how to select all checkbox of the grid. In this it selects all the checkbox on all the pages of the grid.

What I want is it should be able to check all the items on that particular page of the grid.

So if I am on 1st page and I hit check all button then it should check all the checkbox on that page. Now when I go to next page and hit check all then it should select all checkbox on second page of grid....so on same way for uncheck all too........................

 

Can any one help me out with this implementation.........

Thanks

Aniketh

 
New Post
4/12/2008 7:44 AM
 

Well you can try something like this

 

Sub CheckAll(ByVal Check as Boolean)

Dim c As CheckBox

For each r as Row in GridView1.Rows

c=CType(r.FindControl("MyCheckBox"), CheckBox)

If Not c is Nothing

c.Checked = Check

End If

End For

End Sub

 
New Post
4/12/2008 10:56 AM
 

Just the other day I needed the same functionality for checkboxes in a GridView so wrote a short Javascript function that is registered as a client script block during the Pre_Render event. In the following,

btnSelectAll and btnClearSelected are references to two LinkButtons
gvExpiredPosts is a reference to the GridView
'cbSelected' is the ID of the CheckBox controls placed in a TemplateColumn of the GridView

Here's the code (Note: remove space between java and script):

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            
      btnSelectAll.OnClientClick = "java script:return setAllSelected('" & gvExpiredPosts.ClientID & "', true);"
      btnClearSelected.OnClientClick = "java script:return setAllSelected('" & gvExpiredPosts.ClientID & "', false);"
      
      'other code here
End Sub


Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
     Dim sb As New StringBuilder
            
     sb.AppendLine("function setAllSelected(gvCtrlID, selected) {")
     sb.AppendLine("    var gvCtrl = document.getElementById(gvCtrlID);")
     sb.AppendLine("    if (gvCtrl) {")
     sb.AppendLine("         var cbs = gvCtrl.getElementsByTagName('input');")
     sb.AppendLine("         for (var i=0; i < cbs.length; i++) {")
     sb.AppendLine("            var cb = cbs[i];")
     sb.AppendLine("            if (cb.type == 'checkbox' && cb.id.indexOf('cbSelected',0) >= 0) {")
     sb.AppendLine("               cb.checked = selected;")
     sb.AppendLine("            }")
     sb.AppendLine("         }")
     sb.AppendLine("         return false;")
     sb.AppendLine("   }")
     sb.AppendLine("   return true;")
     sb.AppendLine("}")

     If Not Page.ClientScript.IsClientScriptBlockRegistered(Me.GetType, "EPrayer_MngExp") Then
         Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "EPrayer_MngExp", sb.ToString, True)
     End If
 End Sub

 


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...select all checkbox on page of a gridselect all checkbox on page of a grid


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out