Datagrid EditItemTemplate not passing Updated Value

Posted on 2004-11-30
Medium Priority
Last Modified: 2008-02-26
I have a datagrid edititemtemplate column (ordinal value [2]) with a textbox called “txtEditItemDeptName”. When I go to update the record, “txtEditItemDeptName” is always equal to the old value.

For example in the datagrid I have a row called “test”. I hit edit and the textbox comes up, and I type in “test 2”. The value that is getting passed behind the scenes is “test”, not “test 2”.

I have just added some sorting and paging functions which I think have affected this somehow. Any ideas?

 Private Sub dgDeptMaint_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgDeptMaint.UpdateCommand
        Dim strDeptNum As String
        Dim strDeptNameUpdate As String

        'Attach datagrid edit items to the variables.
        strDeptNum = CType(e.Item.FindControl("lblDeptNo_EditItem"), Label).Text
        ****----->strDeptNameUpdate = CType(e.Item.Cells(2).FindControl("txtEditItemDeptName"), TextBox).Text
        strSQLQuery = "UPDATE JJORA.TBLBNK_Dept SET BNK_Dept_NM = " & myHelper.DoubleUpQuotes(strDeptNameUpdate) & " " & _
                      " WHERE BNK_Dept_NO = " & myHelper.DoubleUpQuotes(strDeptNum)

        lblStatus.CssClass() = "DARKBLUETEXT"
        lblStatus.Text = "You just updated Dept: " & strDeptNameUpdate

        'Set to jump out of Edit Mode
        dgDeptMaint.EditItemIndex = -1


    End Sub

    Private Sub ps_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.dgDeptMaint.CurrentPageIndex = 0
    End Sub

    Private Sub dgDeptMaint_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgDeptMaint.PageIndexChanged
        dgDeptMaint.CurrentPageIndex = e.NewPageIndex
    End Sub

    Private Sub dgDeptMaint_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dgDeptMaint.SortCommand

            If viewstate("sortdirection") = "ASC" Then
                viewstate("sortdirection") = "DESC"
                viewstate("sortdirection") = "ASC"
            End If

    End Sub

Question by:shorriga
1 Comment

Accepted Solution

Gregsy earned 2000 total points
ID: 12706062
Its possible that something in your page load is reloading the values, are the initial values being loaded on Page_Load? if so ensure they are in an if not page.ispostback block.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question