Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with gridview

Problem with gridview

Scheduled Pinned Locked Moved ASP.NET
regexhtmlcsshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    indiaone
    wrote on last edited by
    #1

    Hi, In Grid view header i putted one checkbox and inside gridview also having checkbox and one button outside the grid. when i click button it's give me dgridview header checkbox check or not. but it's giving me null. this code giving me null. CheckBox chkAllDelete = (CheckBox)GridView1.HeaderRow.FindControl("chkAll"); when i m trying to find this control.i m getting null value. my code: This code in Html part var counter = 0; var pattern = '^GridView1'; // Get the checkboxes inside the Gridview which is part of the template column function GetChildCheckBoxCount() { var checkBoxCount = 0; var elements = document.getElementsByTagName("INPUT"); for(i=0; i<elements.length;i++) { if(IsCheckBox(elements[i]) && IsMatch(elements[i].id)) checkBoxCount++; } return parseInt(checkBoxCount); } // A function that checks if the checkboxes are the one inside the GridView function IsMatch(id) { var regularExpresssion = new RegExp(pattern); if(id.match(regularExpresssion)) return true; else return false; } function IsCheckBox(chk) { if(chk.type == 'checkbox') return true; else return false; } function AttachListener() { var elements = document.getElementsByTagName("INPUT"); for(i=0; i< elements.length; i++) { if( IsCheckBox(elements[i]) && IsMatch(elements[i].id)) { AddEvent(elements[i],'click',CheckChild); } } } function CheckChild(e) { var evt = e || window.event; var obj = evt.target || evt.srcElement if(obj.checked) { if(counter < GetChildCheckBoxCount()) { counter++; } } else { if(counter > 0) { counter--; } } if(counter == GetChildCheckBoxCount()) { document.getElementById("chkAll").checked = true; } else if(counter < GetChildCheckBoxCount()) { document.getElementById("chkAll").checked = false; } } function AddEvent(obj, evType, fn) { if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent) { </x-turndown>

    K 1 Reply Last reply
    0
    • I indiaone

      Hi, In Grid view header i putted one checkbox and inside gridview also having checkbox and one button outside the grid. when i click button it's give me dgridview header checkbox check or not. but it's giving me null. this code giving me null. CheckBox chkAllDelete = (CheckBox)GridView1.HeaderRow.FindControl("chkAll"); when i m trying to find this control.i m getting null value. my code: This code in Html part var counter = 0; var pattern = '^GridView1'; // Get the checkboxes inside the Gridview which is part of the template column function GetChildCheckBoxCount() { var checkBoxCount = 0; var elements = document.getElementsByTagName("INPUT"); for(i=0; i<elements.length;i++) { if(IsCheckBox(elements[i]) && IsMatch(elements[i].id)) checkBoxCount++; } return parseInt(checkBoxCount); } // A function that checks if the checkboxes are the one inside the GridView function IsMatch(id) { var regularExpresssion = new RegExp(pattern); if(id.match(regularExpresssion)) return true; else return false; } function IsCheckBox(chk) { if(chk.type == 'checkbox') return true; else return false; } function AttachListener() { var elements = document.getElementsByTagName("INPUT"); for(i=0; i< elements.length; i++) { if( IsCheckBox(elements[i]) && IsMatch(elements[i].id)) { AddEvent(elements[i],'click',CheckChild); } } } function CheckChild(e) { var evt = e || window.event; var obj = evt.target || evt.srcElement if(obj.checked) { if(counter < GetChildCheckBoxCount()) { counter++; } } else { if(counter > 0) { counter--; } } if(counter == GetChildCheckBoxCount()) { document.getElementById("chkAll").checked = true; } else if(counter < GetChildCheckBoxCount()) { document.getElementById("chkAll").checked = false; } } function AddEvent(obj, evType, fn) { if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent) { </x-turndown>

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      Since you are using asp.net why are you using input html controls for your checkboxes instead of asp.net checkbox server control? Ben

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups