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. How to Edit a gridview ,Please correct the code which i gave here.

How to Edit a gridview ,Please correct the code which i gave here.

Scheduled Pinned Locked Moved ASP.NET
tutorialannouncement
5 Posts 5 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.
  • R Offline
    R Offline
    rinku soni 23
    wrote on last edited by
    #1

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //TextBox t= (TextBox )GridView1.Rows[e.RowIndex ].FindControl ("txtId"); //TextBox t2=(TextBox )GridView1.Rows[e.RowIndex ].FindControl ("txtName"); GridViewRow row = GridView1.Rows[e.RowIndex]; TextBox t = (TextBox)row.FindControl("txtId"); TextBox t2 = (TextBox)row.FindControl("txtName"); con.Open(); cmd = new OdbcCommand("update table AdminAddNewItem set Node_Name= '" + t2.Text + "' where Node_Id=" + t.Text, con); cmd.ExecuteNonQuery(); con.Close();

    C N R 3 Replies Last reply
    0
    • R rinku soni 23

      protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //TextBox t= (TextBox )GridView1.Rows[e.RowIndex ].FindControl ("txtId"); //TextBox t2=(TextBox )GridView1.Rows[e.RowIndex ].FindControl ("txtName"); GridViewRow row = GridView1.Rows[e.RowIndex]; TextBox t = (TextBox)row.FindControl("txtId"); TextBox t2 = (TextBox)row.FindControl("txtName"); con.Open(); cmd = new OdbcCommand("update table AdminAddNewItem set Node_Name= '" + t2.Text + "' where Node_Id=" + t.Text, con); cmd.ExecuteNonQuery(); con.Close();

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Apart from the part where your code is broken and I can erase your entire database with it ? What's happening with this code ? Why do you feel it needs correcting ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      A 1 Reply Last reply
      0
      • R rinku soni 23

        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //TextBox t= (TextBox )GridView1.Rows[e.RowIndex ].FindControl ("txtId"); //TextBox t2=(TextBox )GridView1.Rows[e.RowIndex ].FindControl ("txtName"); GridViewRow row = GridView1.Rows[e.RowIndex]; TextBox t = (TextBox)row.FindControl("txtId"); TextBox t2 = (TextBox)row.FindControl("txtName"); con.Open(); cmd = new OdbcCommand("update table AdminAddNewItem set Node_Name= '" + t2.Text + "' where Node_Id=" + t.Text, con); cmd.ExecuteNonQuery(); con.Close();

        N Offline
        N Offline
        Nishant Singh
        wrote on last edited by
        #3

        Use stored procedure...or atleast use parametrised Query , Please don't write like this

        1 Reply Last reply
        0
        • R rinku soni 23

          protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //TextBox t= (TextBox )GridView1.Rows[e.RowIndex ].FindControl ("txtId"); //TextBox t2=(TextBox )GridView1.Rows[e.RowIndex ].FindControl ("txtName"); GridViewRow row = GridView1.Rows[e.RowIndex]; TextBox t = (TextBox)row.FindControl("txtId"); TextBox t2 = (TextBox)row.FindControl("txtName"); con.Open(); cmd = new OdbcCommand("update table AdminAddNewItem set Node_Name= '" + t2.Text + "' where Node_Id=" + t.Text, con); cmd.ExecuteNonQuery(); con.Close();

          R Offline
          R Offline
          Raja Soosai
          wrote on last edited by
          #4

          Hi, Please use the following line to access the data grid textbox value from code behind Convert.ToString(CType(GridView1.Rows(i).FindControl("Text1"), Textbox).Text) Thanks, Raja.S

          1 Reply Last reply
          0
          • C Christian Graus

            Apart from the part where your code is broken and I can erase your entire database with it ? What's happening with this code ? Why do you feel it needs correcting ?

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            A Offline
            A Offline
            Arnalyn
            wrote on last edited by
            #5

            :zzz: X| :| :~:confused::mad: :wtf: :omg: :laugh: ;) :(( :-\ :-\ :suss:

            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