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. DataGrid to DataBase

DataGrid to DataBase

Scheduled Pinned Locked Moved ASP.NET
databasecsshelptutorialquestion
4 Posts 3 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.
  • T Offline
    T Offline
    Terick
    wrote on last edited by
    #1

    Hi, I have a DataGrid with the following columns: Remove, ItemName, ItemID, Size, Date, Amount. When the user clicks "Save" I need to cycle through the grid and if any of the Remove Checkboxes are checked, that row needs to get removed, but if the row isnt checked it gets saved to the database using a stored procedure with inputs (Project_ID, ItemID, Size, User). I know how to go through the DataGrid to check to see if the checkbox is checked and then to remove it, but I'm not sure how to take the non-checked rows and add them to the database. Can someone please help me with this code?

    protected void btnSave_onClick(object sender, EventArgs e)
    {
    foreach (GridViewRow row in Control.GridViewRows)
    {
    CheckBox cboxremove = (CheckBox)row.FindControl("cbxRemove");
    if (cboxremove.Checked)
    {
    RemoveCheckedTitles();
    }
    else
    {
    ???????????????
    }
    }

    Please Help! Thanks

    N 1 Reply Last reply
    0
    • T Terick

      Hi, I have a DataGrid with the following columns: Remove, ItemName, ItemID, Size, Date, Amount. When the user clicks "Save" I need to cycle through the grid and if any of the Remove Checkboxes are checked, that row needs to get removed, but if the row isnt checked it gets saved to the database using a stored procedure with inputs (Project_ID, ItemID, Size, User). I know how to go through the DataGrid to check to see if the checkbox is checked and then to remove it, but I'm not sure how to take the non-checked rows and add them to the database. Can someone please help me with this code?

      protected void btnSave_onClick(object sender, EventArgs e)
      {
      foreach (GridViewRow row in Control.GridViewRows)
      {
      CheckBox cboxremove = (CheckBox)row.FindControl("cbxRemove");
      if (cboxremove.Checked)
      {
      RemoveCheckedTitles();
      }
      else
      {
      ???????????????
      }
      }

      Please Help! Thanks

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      else
      {
      // call your stored procedure here for non checked item
      }

      Navaneeth How to use google | Ask smart questions

      T 1 Reply Last reply
      0
      • N N a v a n e e t h

        else
        {
        // call your stored procedure here for non checked item
        }

        Navaneeth How to use google | Ask smart questions

        T Offline
        T Offline
        Terick
        wrote on last edited by
        #3

        Thank you for your reply, however, I am not sure how to read in the data from the columns (columns: Remove, ItemName, ItemID, Size, Date, Amount) into my stored procedure that takes the following inputs (Project Id, ItemID, Size, User) where ProjectID and User are from the session but ItemID and Size are from the DataGrid.

        S 1 Reply Last reply
        0
        • T Terick

          Thank you for your reply, however, I am not sure how to read in the data from the columns (columns: Remove, ItemName, ItemID, Size, Date, Amount) into my stored procedure that takes the following inputs (Project Id, ItemID, Size, User) where ProjectID and User are from the session but ItemID and Size are from the DataGrid.

          S Offline
          S Offline
          Satish Mahapatra
          wrote on last edited by
          #4

          I think you can implement template field for those columns ,from where you want the data to be retrieved just like you are using the checkboxes and getting it by using row.findcontrol ,same try for this template field also.

          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