Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6221589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:09:40+00:00 2026-05-24T08:09:40+00:00

I have a gridview and use a session to pass the variables from the

  • 0

I have a gridview and use a session to pass the variables from the page to an edit page. This works perfectly, until you search for a number. When you search the correct record displays in gridview, but when you click edit, it passes the wrong record.

Private Sub gridview1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
    Session("wr_id") = GridView1.Rows(e.NewEditIndex).Cells(2).Text & "~\/~" & _
                GridView1.Rows(e.NewEditIndex).Cells(3).Text & "~\/~" & _
                GridView1.Rows(e.NewEditIndex).Cells(4).Text & "~\/~" & _
                GridView1.Rows(e.NewEditIndex).Cells(5).Text & "~\/~" & _
                GridView1.Rows(e.NewEditIndex).Cells(6).Text & "~\/~" & _
                GridView1.Rows(e.NewEditIndex).Cells(7).Text & "~\/~" & _
                GridView1.Rows(e.NewEditIndex).Cells(8).Text & "~\/~" & _
                GridView1.Rows(e.NewEditIndex).Cells(9).Text & "~\/~" & _
                GridView1.Rows(e.NewEditIndex).Cells(10).Text & "~\/~" 
                Response.Redirect("WorkEdit.aspx")
End Sub

GRIDVIEW Page

Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
    Dim strPost As Boolean = HiddenSearch.Value
    If strPost = True Then
        Dim strNumber As String
        Dim Dropdown As String
        strNumber = Search_text.Text
        Dropdown = Search_Field.SelectedValue
        If Dropdown = "WO#" Then
            Convert.ToInt32(strNumber)
        End If
        Try
            SqlDataSource1.SelectCommand = "SELECT * FROM [WorkOrderLog] WHERE " + Dropdown + " = '" + strNumber + "' ORDER BY [WO#] DESC"
            SqlDataSource1.Select(DataSourceSelectArguments.Empty)
            SqlDataSource1.DataBind()
            GridView1.DataBind()
        Catch
            'output messagebox for debug
            Dim strPrompt As String
            strPrompt = "Something bad happened, check search text and try again."
            Dim strScript As String = "<script language=JavaScript>"
            strScript += "alert(' " & strPrompt & "');"
            strScript += "</script>"
            Search_text.Focus()
        End Try
    Else
        Search_text.Focus()
    End If


End Sub

WORDEDIT Page

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    'change submit button on mouseover events
    Submit_Button.Attributes.Add("onmouseover", "this.src='../images/Submitdown.png'")
    Submit_Button.Attributes.Add("onmouseout", "this.src='../images/Submitup.png'")
    'change clear button on mouseover events
    Clear.Attributes.Add("onmouseover", "this.src='../images/Cancel(down).png'")
    Clear.Attributes.Add("onmouseout", "this.src='../images/Cancel(up).png'")
    Call Keypress_ALegal()
    Call Keypress_ASite()
    errorWOName.Text = HiddenWOName.Value
    errorLegalDesc.Text = HiddenLegalDesc.Value
    errorLocationNumber.Text = HiddenLocationNumber.Value
    errorDesc.Text = HiddenDesc.Value
    errorSiteNumber.Text = HiddenSiteNumber.Value

    If Not Page.IsPostBack Then

        'Get session info
        lblID.Text = "Session Variable Was Lost"
        If (Session("wr_id") <> "") Then
            Dim strSession As String = Session("wr_id")
            Dim sessionArray As Array
            'split session into array at ~\/~ 
            sessionArray = Split(Session("wr_id"), "~\/~")
            'assign textbox/dropdowns values passed from split variables
            lblID.Text = sessionArray(0)
            'WO Name
            If sessionArray(1) = "&nbsp;" Then
                WOName.Text = ""
            Else
                WOName.Text = sessionArray(1)
            End If
            Location.Text = sessionArray(2)
            'LegalDesc
            If sessionArray(3) = "&nbsp;" Then
                LegalDesc.Text = ""
            Else
                LegalDesc.Text = sessionArray(3)
            End If
            'Trans ADDED
            If sessionArray(4) = "&nbsp;" Then
                TransADDED.Text = ""
            Else
                TransADDED.Text = sessionArray(4)
            End If
            'Trans Retired
            If sessionArray(5) = "&nbsp;" Then
                TransRETIRED.Text = ""
            Else
                TransRETIRED.Text = sessionArray(5)
            End If
            If sessionArray(6) = "&nbsp;" Then
                Description.Text = ""
            Else
                Description.Text = sessionArray(6)
            End If
            If sessionArray(7) = "1/1/1900 12:00:00 AM" Or sessionArray(7) = "&nbsp;" Then
                Started.Text = ""
            Else
                Started.Text = (CType((sessionArray(7)), DateTime).ToString("MM/dd/yyyy HH:mm tt"))
            End If
            If sessionArray(8) = "1/1/1900 12:00:00 AM" Or sessionArray(8) = "&nbsp;" Then
                Completed.Text = ""
            ElseIf sessionArray(8) = "&nbsp;" Then
                Completed.Text = ""
            Else
                Completed.Text = (CType((sessionArray(8)), DateTime).ToString("MM/dd/yyyy HH:mm tt"))
            End If
            StakedBy.SelectedValue = sessionArray(9)

I realize not all of the code is pasted in here, because it would take too much space. Any Ideas? I’m guessing it has something to do with e.NewEditIndex

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:09:41+00:00Added an answer on May 24, 2026 at 8:09 am

    The solution to the problem was wrapping the pageload in a if, ispostback statement. Thank you for your help rkw.

       Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
            If Search_text.Text = "" Then
                SqlDataSource1.SelectCommand = "SELECT * FROM [WorkOrderLog] ORDER BY [WO#] DESC"
                SqlDataSource1.Select(DataSourceSelectArguments.Empty)
                SqlDataSource1.DataBind()
                GridView1.DataBind()
            Else
            End If
        End If
            If Not IsPostBack Then
                SqlDataSource1.SelectCommand = "SELECT * FROM [WorkOrderLog] ORDER BY [WO#] DESC"
                SqlDataSource1.Select(DataSourceSelectArguments.Empty)
                SqlDataSource1.DataBind()
                GridView1.DataBind()
            End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have to fix the header in a gridview and i use this in
I have a master-detail page, in which I use GridView to display multiple rows
I have a gridview which should allow rows to be in edit mode. this
I have a page using ASPxGridView and to fill the GridView I use a
I have a GridView being populated from a non-SQL database that we use internally.
I currently have a Gridview , And I want to use client-side validation to
i have little dilemma, i often use data-bound controls such as Gridview in conjunction
I have a GridView defined like this: <asp:GridView ID=myGridView ruant=server> <asp:BoundField DataField=myField /> <asp:CommandField
Afternoon all. I have the following scenario: I have a search page where by
I tried to post the selected ID number from source page into a new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.