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. gridview to database

gridview to database

Scheduled Pinned Locked Moved ASP.NET
databasetutorial
3 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.
  • S Offline
    S Offline
    sangramkp
    wrote on last edited by
    #1

    Hi i have a gridView with 4columns(Btncolumn, StartAmount, EndAmount, AccountShare which is bound to a datatable. I want to store the last 3 columns value in a database in tblSlab taking either from gridView or datatable..... how to do this....

    Sangram (A battle with self) Life is simple, we are the ones makes the living difficult

    N E 2 Replies Last reply
    0
    • S sangramkp

      Hi i have a gridView with 4columns(Btncolumn, StartAmount, EndAmount, AccountShare which is bound to a datatable. I want to store the last 3 columns value in a database in tblSlab taking either from gridView or datatable..... how to do this....

      Sangram (A battle with self) Life is simple, we are the ones makes the living difficult

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

      sangramkp wrote:

      I want to store the last 3 columns value in a database in tblSlab taking either from gridView or datatable.....

      for(int i=Datatable.Row.Count-3;i<Datatable.Row.Count;i++)
      {
      //Get values from DT
      //Form query and execute
      }


      My Website | Ask smart questions

      1 Reply Last reply
      0
      • S sangramkp

        Hi i have a gridView with 4columns(Btncolumn, StartAmount, EndAmount, AccountShare which is bound to a datatable. I want to store the last 3 columns value in a database in tblSlab taking either from gridView or datatable..... how to do this....

        Sangram (A battle with self) Life is simple, we are the ones makes the living difficult

        E Offline
        E Offline
        ElSpinos
        wrote on last edited by
        #3

        Hi there sangramkp, From what i understand in your requirement is that you want to take the values from an already populated GridView control and insert the last three columns into a table called tblSlab. You will need to iterate through the GridView's Rows property and extract the cells by index since you know which ones you need, consider the following code:

          foreach (GridViewRow row in GridView.Rows)
          {
           // You indicated you wanted the last three cells...
           // Note that the cells collection is zero based...
           sqlScript = "Insert Into tblSlab Values(" + row.Cells[1].Text + ", " + row.Cells[2].Text + ", " + row.Cells[3].Text + ", ";
           // Now execute your code to insert the record into your table...
          }
        

        And thats it... Have fun! :) -- modified at 6:18 Friday 14th September, 2007

        Fernando Mendes Senior .NET Developer, Architect

        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