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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. render values from check box and update to database on button click

render values from check box and update to database on button click

Scheduled Pinned Locked Moved ASP.NET
questiondatabaseannouncement
5 Posts 2 Posters 1 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.
  • S Offline
    S Offline
    srishree
    wrote on last edited by
    #1

    I have a gridview which contains columns retreived from the database.i have in total 12 columns,in which 4 columns have checkbox's where ever there is a null in the database.i have done tht on the rowdatabound event of gridview dynamically by calling CheckBox cb= new CheckBox(); i also have a checkbox in the first column of the gridview created using an itemTemplate tag of gridview,so tht when we check the corresponding row's checkbox,the values in tht row shall be updated now my question is,i want to check the boxes in the column cells and update those corresponding row values in the database on button click.and also i need the checkbox state to be maintained.......how can i do this?any responses will be appreciated.

    hi

    T 1 Reply Last reply
    0
    • S srishree

      I have a gridview which contains columns retreived from the database.i have in total 12 columns,in which 4 columns have checkbox's where ever there is a null in the database.i have done tht on the rowdatabound event of gridview dynamically by calling CheckBox cb= new CheckBox(); i also have a checkbox in the first column of the gridview created using an itemTemplate tag of gridview,so tht when we check the corresponding row's checkbox,the values in tht row shall be updated now my question is,i want to check the boxes in the column cells and update those corresponding row values in the database on button click.and also i need the checkbox state to be maintained.......how can i do this?any responses will be appreciated.

      hi

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      To make this just a bit easier. Create a template column in your gridview. Hide the checkboxe in the itembound event when the database value is null. That solves the problem of maintaining the viewstate of the grid. Now to loop through your gridview. Here is some sample code to put behind your button (or during any event really). CheckBox cb; foreach (GridViewRow r in this.GridView1.Rows) { cb = (CheckBox)r.FindControl("cbUpdate"); if (cb.Checked) { //put code to update database } }

      GameFly free trial

      S 1 Reply Last reply
      0
      • T ToddHileHoffer

        To make this just a bit easier. Create a template column in your gridview. Hide the checkboxe in the itembound event when the database value is null. That solves the problem of maintaining the viewstate of the grid. Now to loop through your gridview. Here is some sample code to put behind your button (or during any event really). CheckBox cb; foreach (GridViewRow r in this.GridView1.Rows) { cb = (CheckBox)r.FindControl("cbUpdate"); if (cb.Checked) { //put code to update database } }

        GameFly free trial

        S Offline
        S Offline
        srishree
        wrote on last edited by
        #3

        Thanks for the reply.but it has not solved my problem completely.i have done similar to what u have replied,but in my case i need to loop through the inner cells of the gridview and as well the rows and check if there is a checkbox at any cell in the gridview,if exists,based upon my requirement i have to click the checkbox in those cells and also check the checkbox in the first column,and then update.what i want is to check the checkbox in the gridview cells and also the checkbox field created using the itemtemplate in the gridview.when i check the cells with checkboxes and then check the checkbox that is existing in the first column of the gridview and click the update button,then the data in the corresponding row should update.....

        hi

        T 1 Reply Last reply
        0
        • S srishree

          Thanks for the reply.but it has not solved my problem completely.i have done similar to what u have replied,but in my case i need to loop through the inner cells of the gridview and as well the rows and check if there is a checkbox at any cell in the gridview,if exists,based upon my requirement i have to click the checkbox in those cells and also check the checkbox in the first column,and then update.what i want is to check the checkbox in the gridview cells and also the checkbox field created using the itemtemplate in the gridview.when i check the cells with checkboxes and then check the checkbox that is existing in the first column of the gridview and click the update button,then the data in the corresponding row should update.....

          hi

          T Offline
          T Offline
          ToddHileHoffer
          wrote on last edited by
          #4

          srishree wrote:

          Thanks for the reply.but it has not solved my problem completely.i have done similar to what u have replied,but in my case i need to loop through the inner cells of the gridview and as well the rows and check if there is a checkbox at any cell in the gridview,if exists,based upon my requirement i have to click the checkbox in those cells and also check the checkbox in the first column,and then update.what i want is to check the checkbox in the gridview cells and also the checkbox field created using the itemtemplate in the gridview.when i check the cells with checkboxes and then check the checkbox that is existing in the first column of the gridview and click the update button,then the data in the corresponding row should update.....

          Do you have a question?

          GameFly free trial

          S 1 Reply Last reply
          0
          • T ToddHileHoffer

            srishree wrote:

            Thanks for the reply.but it has not solved my problem completely.i have done similar to what u have replied,but in my case i need to loop through the inner cells of the gridview and as well the rows and check if there is a checkbox at any cell in the gridview,if exists,based upon my requirement i have to click the checkbox in those cells and also check the checkbox in the first column,and then update.what i want is to check the checkbox in the gridview cells and also the checkbox field created using the itemtemplate in the gridview.when i check the cells with checkboxes and then check the checkbox that is existing in the first column of the gridview and click the update button,then the data in the corresponding row should update.....

            Do you have a question?

            GameFly free trial

            S Offline
            S Offline
            srishree
            wrote on last edited by
            #5

            yes,the question is in my previous mail,to simultaneously check the chekbox in the cells of cells[7],cells[8],cells[10],cells[11] and then click the checkbox in the itemtemplate to update it to the database. how to do this?

            hi

            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