Urgent.. prob w/ Datagrid edit button

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • slinky

    Urgent.. prob w/ Datagrid edit button

    I had a successfully deployed datagrid reading an XML file and
    showing the data:

    Private Function MakeDataView() as DataView
    Dim myDataSet As New DataSet()
    myDataSet.ReadX ml(Server.MapPa th("TimberSales .xml"))
    Dim view As DataView = New DataView(myData Set.Tables(0))
    view.AllowDelet e = False
    view.AllowEdit = True
    view.AllowNew = False
    view.Sort = "Year ASC"
    Return view
    End Function


    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim view as DataView = MakeDataView()
    dgTimber.DataSo urce = view
    dgTimber.AllowS orting = True
    dgTimber.DataBi nd()
    End Sub
    _______________ _______________ _______________ _______________ __________


    I wanted to add an "Edit" button as desribed at:
    Gain technical skills through documentation and training, earn certifications and connect with the community



    Private Sub dgTimber_EditCo mmand(ByVal source As Object, _
    ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
    Handles dgTimber.EditCo mmand
    dgTimber.EditIt emIndex = e.Item.ItemInde x
    dgTimber.DataBi nd()
    End Sub


    Dim newData As String
    Dim aTextBox As TextBox
    aTextBox = CType(e.Item.Ce lls(1).Controls (0), TextBox)
    **** says "aTextBox" is not declared, (?)
    newData =
    aTextBox.Text **** says
    "newData" is not declared, (?)


    Private Sub dgTimber_Update Command(ByVal source As Object, _
    ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
    Handles dgTimber.Update Command
    Dim quantityCell As TableCell = e.Item.Cells(6)
    Dim quantityBox As TextBox = _
    CType(quantityC ell.Controls(0) , TextBox)
    Dim quantity As Integer =
    System.Int32.Pa rse(quantityBox .Text)
    dgTimber.EditIt emIndex = -1
    dgTimber.DataBi nd()
    End Sub


    When I hit the Edit Button I get this:


    Invalid postback or callback argument. Event validation is
    enabled
    using <pages enableEventVali dation="true"/>
    in configuration or <%@ Page EnableEventVali dation="true" %in a
    page. For security purposes, this feature ....etc.


    Does anything obvious stabd out as the potential probelm? Thank You!
  • rote

    #2
    Re: Urgent.. prob w/ Datagrid edit button

    Have you tried setting it to false and see
    Patrick

    "slinky" <campbellbrian2 001@yahoo.comwr ote in message
    news:5bdaa920-b65f-4446-b848-e564e4b8550f@h2 g2000hsg.google groups.com...
    >I had a successfully deployed datagrid reading an XML file and
    showing the data:
    >
    Private Function MakeDataView() as DataView
    Dim myDataSet As New DataSet()
    myDataSet.ReadX ml(Server.MapPa th("TimberSales .xml"))
    Dim view As DataView = New DataView(myData Set.Tables(0))
    view.AllowDelet e = False
    view.AllowEdit = True
    view.AllowNew = False
    view.Sort = "Year ASC"
    Return view
    End Function
    >
    >
    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim view as DataView = MakeDataView()
    dgTimber.DataSo urce = view
    dgTimber.AllowS orting = True
    dgTimber.DataBi nd()
    End Sub
    _______________ _______________ _______________ _______________ __________
    >
    >
    I wanted to add an "Edit" button as desribed at:
    Gain technical skills through documentation and training, earn certifications and connect with the community

    >
    >
    Private Sub dgTimber_EditCo mmand(ByVal source As Object, _
    ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
    Handles dgTimber.EditCo mmand
    dgTimber.EditIt emIndex = e.Item.ItemInde x
    dgTimber.DataBi nd()
    End Sub
    >
    >
    Dim newData As String
    Dim aTextBox As TextBox
    aTextBox = CType(e.Item.Ce lls(1).Controls (0), TextBox)
    **** says "aTextBox" is not declared, (?)
    newData =
    aTextBox.Text **** says
    "newData" is not declared, (?)
    >
    >
    Private Sub dgTimber_Update Command(ByVal source As Object, _
    ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
    Handles dgTimber.Update Command
    Dim quantityCell As TableCell = e.Item.Cells(6)
    Dim quantityBox As TextBox = _
    CType(quantityC ell.Controls(0) , TextBox)
    Dim quantity As Integer =
    System.Int32.Pa rse(quantityBox .Text)
    dgTimber.EditIt emIndex = -1
    dgTimber.DataBi nd()
    End Sub
    >
    >
    When I hit the Edit Button I get this:
    >
    >
    Invalid postback or callback argument. Event validation is
    enabled
    using <pages enableEventVali dation="true"/>
    in configuration or <%@ Page EnableEventVali dation="true" %in a
    page. For security purposes, this feature ....etc.
    >
    >
    Does anything obvious stabd out as the potential probelm? Thank You!

    Comment

    • slinky

      #3
      Re: Urgent.. prob w/ Datagrid edit button

      Thanks... that worked... now I need to write an event handler for the
      buttons:

      My code within the datagrid describes the buttons:

      <asp:EditComman dColumn ButtonType="Pus hButton"
      CancelText="Can cel"
      EditText="Edit" UpdateText="Upd ate"
      CausesValidatio n="false"></asp:EditCommand Column>

      I'm having difficulty following the tutorial's association with this
      dg's button and this code:

      Private Sub dgTimber_EditCo mmand(ByVal source As Object, _
      ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
      Handles dgTimber.EditCo mmand
      dgTimber.EditIt emIndex = e.Item.ItemInde x
      dgTimber.DataBi nd()
      End Sub

      Private Sub dgTimber_Update Command(ByVal source As Object, _
      ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
      Handles dgTimber.Update Command
      Dim quantityCell As TableCell = e.Item.Cells(6)
      Dim quantityBox As TextBox = _
      CType(quantityC ell.Controls(0) , TextBox)
      Dim quantity As Integer =
      System.Int32.Pa rse(quantityBox .Text)
      dgTimber.EditIt emIndex = -1
      dgTimber.DataBi nd()
      End Sub

      Basically what I want is when I hit the edit button a textbox
      displays below the datagrid and the users can type in the new info and
      the button will change to Update upon which pressing that will write
      the constents of the textbox to the database (and a postback refresh
      will show the updated info).


      On Oct 6, 9:13 pm, "rote" <naijaco...@hot mail.comwrote:
      Have you tried setting it to false and see
      Patrick
      >
      "slinky" <campbellbrian2 ...@yahoo.comwr ote in message
      >
      news:5bdaa920-b65f-4446-b848-e564e4b8550f@h2 g2000hsg.google groups.com...
      >
      >
      >
      I had a successfully deployed datagrid reading an XML file and
      showing the data:
      >
         Private Function MakeDataView() as DataView
             Dim myDataSet As New DataSet()
             myDataSet.ReadX ml(Server.MapPa th("TimberSales .xml"))
             Dim view As DataView = New DataView(myData Set.Tables(0))
             view.AllowDelet e = False
             view.AllowEdit = True
             view.AllowNew = False
             view.Sort = "Year ASC"
             Return view
         End Function
      >
         Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
             Dim view as DataView = MakeDataView()
             dgTimber.DataSo urce = view
             dgTimber.AllowS orting = True
             dgTimber.DataBi nd()
         End Sub
      _______________ _______________ _______________ _______________ __________
      >
      I wanted to add an "Edit" button as desribed at:
      http://msdn.microsoft.com/en-us/libr...8(VS.71).aspx:
      >
         Private Sub dgTimber_EditCo mmand(ByVal source As Object, _
         ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
         Handles dgTimber.EditCo mmand
             dgTimber.EditIt emIndex = e.Item.ItemInde x
             dgTimber.DataBi nd()
         End Sub
      >
             Dim newData As String
             Dim aTextBox As TextBox
                 aTextBox = CType(e.Item.Ce lls(1).Controls (0), TextBox)
      **** says "aTextBox" is not declared, (?)
                 newData =
      aTextBox.Text                                              **** says
      "newData" is not declared, (?)
      >
         Private Sub dgTimber_Update Command(ByVal source As Object, _
         ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
         Handles dgTimber.Update Command
             Dim quantityCell As TableCell = e.Item.Cells(6)
             Dim quantityBox As TextBox = _
                CType(quantityC ell.Controls(0) , TextBox)
             Dim quantity As Integer =
      System.Int32.Pa rse(quantityBox .Text)
             dgTimber.EditIt emIndex = -1
             dgTimber.DataBi nd()
         End Sub
      >
      When I hit the Edit Button I get this:
      >
        Invalid postback or callback argument.  Event validation is
      enabled
      using <pages enableEventVali dation="true"/>
        in configuration or <%@ Page EnableEventVali dation="true" %in a
      page.  For security purposes, this feature ....etc.
      >
      Does anything obvious stabd out as the potential probelm?  Thank You!- Hide quoted text -
      >
      - Show quoted text -

      Comment

      Working...