Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.net Gridview.. something weird
    primarykey
    data
    text
    <p>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.</p> <pre><code>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 &amp; "~\/~" &amp; _ GridView1.Rows(e.NewEditIndex).Cells(3).Text &amp; "~\/~" &amp; _ GridView1.Rows(e.NewEditIndex).Cells(4).Text &amp; "~\/~" &amp; _ GridView1.Rows(e.NewEditIndex).Cells(5).Text &amp; "~\/~" &amp; _ GridView1.Rows(e.NewEditIndex).Cells(6).Text &amp; "~\/~" &amp; _ GridView1.Rows(e.NewEditIndex).Cells(7).Text &amp; "~\/~" &amp; _ GridView1.Rows(e.NewEditIndex).Cells(8).Text &amp; "~\/~" &amp; _ GridView1.Rows(e.NewEditIndex).Cells(9).Text &amp; "~\/~" &amp; _ GridView1.Rows(e.NewEditIndex).Cells(10).Text &amp; "~\/~" Response.Redirect("WorkEdit.aspx") End Sub </code></pre> <p>GRIDVIEW Page</p> <pre><code>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 = "&lt;script language=JavaScript&gt;" strScript += "alert(' " &amp; strPrompt &amp; "');" strScript += "&lt;/script&gt;" Search_text.Focus() End Try Else Search_text.Focus() End If End Sub </code></pre> <p>WORDEDIT Page</p> <pre><code>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") &lt;&gt; "") 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) = "&amp;nbsp;" Then WOName.Text = "" Else WOName.Text = sessionArray(1) End If Location.Text = sessionArray(2) 'LegalDesc If sessionArray(3) = "&amp;nbsp;" Then LegalDesc.Text = "" Else LegalDesc.Text = sessionArray(3) End If 'Trans ADDED If sessionArray(4) = "&amp;nbsp;" Then TransADDED.Text = "" Else TransADDED.Text = sessionArray(4) End If 'Trans Retired If sessionArray(5) = "&amp;nbsp;" Then TransRETIRED.Text = "" Else TransRETIRED.Text = sessionArray(5) End If If sessionArray(6) = "&amp;nbsp;" Then Description.Text = "" Else Description.Text = sessionArray(6) End If If sessionArray(7) = "1/1/1900 12:00:00 AM" Or sessionArray(7) = "&amp;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) = "&amp;nbsp;" Then Completed.Text = "" ElseIf sessionArray(8) = "&amp;nbsp;" Then Completed.Text = "" Else Completed.Text = (CType((sessionArray(8)), DateTime).ToString("MM/dd/yyyy HH:mm tt")) End If StakedBy.SelectedValue = sessionArray(9) </code></pre> <p>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</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload