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 in GridView

How to edit in GridView

Scheduled Pinned Locked Moved ASP.NET
questiontutorial
7 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
    slSoftware
    wrote on last edited by
    #1

    Hi everyone,i'm using GridView for display some details,so i need to allow user's to edit the data GridView it self,so how can i do that using RowCommand Event or is there any easy way to that?,i'm using StoredProcedure for that editing also. thank you.

    V N 2 Replies Last reply
    0
    • S slSoftware

      Hi everyone,i'm using GridView for display some details,so i need to allow user's to edit the data GridView it self,so how can i do that using RowCommand Event or is there any easy way to that?,i'm using StoredProcedure for that editing also. thank you.

      V Offline
      V Offline
      varshavmane
      wrote on last edited by
      #2

      Put the different controls in GridView and in Row command event you will the row index and you can update query for the same.

      S 1 Reply Last reply
      0
      • V varshavmane

        Put the different controls in GridView and in Row command event you will the row index and you can update query for the same.

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

        I didnt get u freind, can u some explain coding for me Thanks

        V 1 Reply Last reply
        0
        • S slSoftware

          I didnt get u freind, can u some explain coding for me Thanks

          V Offline
          V Offline
          varshavmane
          wrote on last edited by
          #4

          I have used checkbox u can use any control in the same way. Try the following: On Row Command: Protected Sub GridViewForm_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridViewForm.RowCommand Dim gvRow As GridViewRow For Each gvRow In GridViewForm.Rows If gvRow.RowType = ListItemType.Item Or gvRow.RowType = ListItemType.AlternatingItem Then If CType(GridViewForm.FindControl("chkAdd"), CheckBox).Checked Then CType(GridViewForm.FindControl("chkView"), CheckBox).Checked = True Else CType(GridViewForm.FindControl("chkView"), CheckBox).Checked = True End If End If Next End Sub Hope this helps u,if not then do reply...

          S 1 Reply Last reply
          0
          • S slSoftware

            Hi everyone,i'm using GridView for display some details,so i need to allow user's to edit the data GridView it self,so how can i do that using RowCommand Event or is there any easy way to that?,i'm using StoredProcedure for that editing also. thank you.

            N Offline
            N Offline
            Nimua
            wrote on last edited by
            #5

            GridView in SmartTag have option allow editing, you should add column CommandField Edit,Update,Cancel Also you should specify in SqlDataSource in Update stored procedure. After that in the grid will appear column with link button Edit. Click it and data in columns with ReadOnly=false will be displayed in textbox.

            1 Reply Last reply
            0
            • V varshavmane

              I have used checkbox u can use any control in the same way. Try the following: On Row Command: Protected Sub GridViewForm_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridViewForm.RowCommand Dim gvRow As GridViewRow For Each gvRow In GridViewForm.Rows If gvRow.RowType = ListItemType.Item Or gvRow.RowType = ListItemType.AlternatingItem Then If CType(GridViewForm.FindControl("chkAdd"), CheckBox).Checked Then CType(GridViewForm.FindControl("chkView"), CheckBox).Checked = True Else CType(GridViewForm.FindControl("chkView"), CheckBox).Checked = True End If End If Next End Sub Hope this helps u,if not then do reply...

              S Offline
              S Offline
              slSoftware
              wrote on last edited by
              #6

              Thnks freind,i have set the edit thing in gridview in different way,that is i use EditItemIndex into -1 and i check it and i put my primary key into DataKeyField,i need according my ID update the data into database,how can i do that.

              V 1 Reply Last reply
              0
              • S slSoftware

                Thnks freind,i have set the edit thing in gridview in different way,that is i use EditItemIndex into -1 and i check it and i put my primary key into DataKeyField,i need according my ID update the data into database,how can i do that.

                V Offline
                V Offline
                varshavmane
                wrote on last edited by
                #7

                U can write the update query on Row Command event of GridView.

                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