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. GridVew Updation

GridVew Updation

Scheduled Pinned Locked Moved ASP.NET
databasetutorialquestionannouncement
2 Posts 2 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.
  • P Offline
    P Offline
    piyush123
    wrote on last edited by
    #1

    How to update a gridview if we have used sqldatasource and updatecommand is storedprocedure,How We can get the edited fields of gridview as a parameters for our stored procedure used here??????

    PIYUSH

    M 1 Reply Last reply
    0
    • P piyush123

      How to update a gridview if we have used sqldatasource and updatecommand is storedprocedure,How We can get the edited fields of gridview as a parameters for our stored procedure used here??????

      PIYUSH

      M Offline
      M Offline
      mdv113
      wrote on last edited by
      #2

      Use the SqlDataSource for this or code it your self. I asume you will not use the SqlDataSource. Steps: 1) fetch the GridViewRowUpdate event 2) compare old and new value 3) create sql statements See sample(you should call your Storedproc with SqlCommand class) Protected Sub GridViewDetectorInstellingen_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridViewDetectorInstellingen.RowUpdating Dim newvals As IOrderedDictionary = e.NewValues Dim oldvals As IOrderedDictionary = e.OldValues 'note TDBP1 is column name in Grid Dim begin As String = newvals.Item("TDBP1").ToString() Dim einde As String = newvals.Item("TDBP2").ToString() Dim oudbegin As String = oldvals.Item("TDBP1").ToString() Dim oudeinde As String = oldvals.Item("TDBP2").ToString() Dim keys As IOrderedDictionary = e.Keys 'Keys are the key columns from the main key of the source table Dim dim1 As String = keys.Item("Dimension1") Dim dim2 As String = keys.Item("Dimension2") Dim kid As String = keys.Item("KID") Dim sql As String Dim pos As Int32 If Not IsNothing(begin) Then If begin <> oudbegin Then pos = begin.IndexOf(":") If pos > -1 Then begin = begin.Remove(begin.IndexOf(":"), 1) End If sql = "update Elementen0 set [Value] = " & begin & " where Dimension1 = " & dim1 & " and Dimension2 = " & dim2 & " and OID = (select ID from Objecten where KID = " & kid & " and Naam = 'TDBP1')" globalstuff.ExecuteNonQuery(sql) End If End If If Not IsNothing(einde) Then If einde <> oudeinde Then pos = einde.IndexOf(":") If pos > -1 Then einde = einde.Remove(einde.IndexOf(":"), 1) End If sql = "update Elementen0 set [Value] = " & einde & " where Dimension1 = " & dim1 & " and Dimension2 = " & dim2 & " and OID = (select ID from Objecten where KID = " & kid & " and Naam = 'TDBP2')" globalstuff.ExecuteNonQuery(sql) End If End If 'no update through SqlDataSource permitted e.Cancel = True 'update is done through code behind so stop editmode Me.GridViewDetectorInstellingen.EditIndex = -1 Me.GridViewDetectorInstellingen.DataBind() End Sub Mdv

      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