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. General Programming
  3. Visual Basic
  4. Update on Grid fails?

Update on Grid fails?

Scheduled Pinned Locked Moved Visual Basic
cssdatabasequestiondiscussionannouncement
2 Posts 1 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
    Sled Dog
    wrote on last edited by
    #1

    I don't understand this one... Almost everything works except the Update on the grid: Delete, Cancel, Edit* If I take the Load_Grid out of m_dgIDs.EditCommand--I have to click the Edit link twice for it to turn into a textbox that I can edit, but the original content is not there. If I leave the Load_Grid in the EditCommand, the textbox will appear immediately with the cell's content and I can edit it. HOWEVER, the grid no longer appears to be bound and this line blows up: Dim id As Integer = CType(e.Item.Cells(0).Text, Integer) e.Item.Cells(0).Text is = "" or nothing I tried to keep this code to a MIMIMUM because I know it is a lot to ask of forum members, but if someone has the time, I would appreciate any thoughts on the subject. Thanks - A Lot. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then Load_DropDown() End If End Sub Private Sub m_ddFacility_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_ddFacility.SelectedIndexChanged Load_Grid() End Sub Private Sub dgIDs_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.UpdateCommand 'ID is just a simple class that interfaces with the database & has 3 properties 'CostCenterID, FacilityID, & Description...pretty trivial Dim oCostCenter As New ID Dim id As Integer = CType(e.Item.Cells(0).Text, Integer) oCostCenter.Load(id) oCostCenter.Description = CType(e.Item.Cells(2).Text, String) oCostCenter.FacilityID = m_ddFacility.SelectedValue oCostCenter.Update() Load_Grid() m_dgIDs.EditItemIndex = -1 End Sub Private Sub dgIDs_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.EditCommand m_dgIDs.EditItemIndex = e.Item.ItemIndex Load_Grid() End Sub Private Sub dgIDs_Delete(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.DeleteCommand Dim oCostCenter As New ID Dim id As Integer = CType(e.Item.Cells(0).Text, Integer) oCostCenter.Load(id) oCostCenter.Delete() Load_Grid() End Sub Private Sub dgIDs_Cancel(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.CancelCommand m_dgIDs.EditItemIndex = -1 Load_Grid() End Sub Private Sub Load_Grid() Dim ds As DataSet Dim oData_Dev As New CFormData("DefaultConnectionString") ds = oData_Dev.GetDataSet("SELECT * FROM CostCenter WHERE FacilityID =

    S 1 Reply Last reply
    0
    • S Sled Dog

      I don't understand this one... Almost everything works except the Update on the grid: Delete, Cancel, Edit* If I take the Load_Grid out of m_dgIDs.EditCommand--I have to click the Edit link twice for it to turn into a textbox that I can edit, but the original content is not there. If I leave the Load_Grid in the EditCommand, the textbox will appear immediately with the cell's content and I can edit it. HOWEVER, the grid no longer appears to be bound and this line blows up: Dim id As Integer = CType(e.Item.Cells(0).Text, Integer) e.Item.Cells(0).Text is = "" or nothing I tried to keep this code to a MIMIMUM because I know it is a lot to ask of forum members, but if someone has the time, I would appreciate any thoughts on the subject. Thanks - A Lot. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then Load_DropDown() End If End Sub Private Sub m_ddFacility_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_ddFacility.SelectedIndexChanged Load_Grid() End Sub Private Sub dgIDs_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.UpdateCommand 'ID is just a simple class that interfaces with the database & has 3 properties 'CostCenterID, FacilityID, & Description...pretty trivial Dim oCostCenter As New ID Dim id As Integer = CType(e.Item.Cells(0).Text, Integer) oCostCenter.Load(id) oCostCenter.Description = CType(e.Item.Cells(2).Text, String) oCostCenter.FacilityID = m_ddFacility.SelectedValue oCostCenter.Update() Load_Grid() m_dgIDs.EditItemIndex = -1 End Sub Private Sub dgIDs_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.EditCommand m_dgIDs.EditItemIndex = e.Item.ItemIndex Load_Grid() End Sub Private Sub dgIDs_Delete(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.DeleteCommand Dim oCostCenter As New ID Dim id As Integer = CType(e.Item.Cells(0).Text, Integer) oCostCenter.Load(id) oCostCenter.Delete() Load_Grid() End Sub Private Sub dgIDs_Cancel(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.CancelCommand m_dgIDs.EditItemIndex = -1 Load_Grid() End Sub Private Sub Load_Grid() Dim ds As DataSet Dim oData_Dev As New CFormData("DefaultConnectionString") ds = oData_Dev.GetDataSet("SELECT * FROM CostCenter WHERE FacilityID =

      S Offline
      S Offline
      Sled Dog
      wrote on last edited by
      #2

      Yeah, I am not sure what the "real" answer was to this. I threw it all away, used the MS example from help--then, added my code back in. I could post it upon request. Thanks Anyway. William :)

      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