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. Urgent

Urgent

Scheduled Pinned Locked Moved ASP.NET
helpjavascriptdatabasequestion
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.
  • G Offline
    G Offline
    Goodway
    wrote on last edited by
    #1

    hi everyone, i have a datagrid that displayed data from a database. i have 2 template columns, the first one with a check box. the second one with a drop down list.When a user change the value in the drop down list the check box should be checked automatically. my code is: Dim item As DataGridItem For Each item In Me.DataGrid1.Items Dim cbRules As CheckBox = item.Cells(0).Controls(1) Dim ddEvent As dropdownlist = item.Cells(14).Controls(1) Me.ddEvent.Attributes.Add("OnChange", "checkcbEvent();") Next the function checkcbEvent() is a javascript function: function checkcbEvent() { document.Form1.cbRules.checked = true; } but it gives me an error: document.Form1.cbRules is null or not an object Can anyone help?????

    A 1 Reply Last reply
    0
    • G Goodway

      hi everyone, i have a datagrid that displayed data from a database. i have 2 template columns, the first one with a check box. the second one with a drop down list.When a user change the value in the drop down list the check box should be checked automatically. my code is: Dim item As DataGridItem For Each item In Me.DataGrid1.Items Dim cbRules As CheckBox = item.Cells(0).Controls(1) Dim ddEvent As dropdownlist = item.Cells(14).Controls(1) Me.ddEvent.Attributes.Add("OnChange", "checkcbEvent();") Next the function checkcbEvent() is a javascript function: function checkcbEvent() { document.Form1.cbRules.checked = true; } but it gives me an error: document.Form1.cbRules is null or not an object Can anyone help?????

      A Offline
      A Offline
      Andrew Quinn AUS
      wrote on last edited by
      #2

      Hi there, This is because cbRules is a server-side variable. You need to add the id to the cbRules control such that the client-side script can find it, e.g. Server-side:

      Dim cbRules as CheckBox = item.Cells(0).Controls(1)
      cbRules.ID = "idCbRules"
      ...
      ...

      Client-side:

      function checkcbEvent()
      {
      var elCb = document.getElementById("idCbRules");
      if (elCb) elCb.checked = true;
      }

      Hope this helps, Andy

      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