Gus Koutsivitis
asked on
Asp.Net GridView Drag and Drop online example update other fields help!
Hi,
Hi, I am using this online solution for Grideview Drag and Drop asp.net web forms (https://www.aspsnippets.com/Articles/Reorder-GridView-Rows-Drag-and-Drop-ordering-of-GridView-Rows-using-jQuery-in-ASPNet.aspx). Everything works fine but now I need help updating the database table with additional fields. For example: I need to update the table of who dragged and dropped the row. I added the "UpdateBy" field to my update statement , it works, but it updates every row with the value not the one row that was dropped. What am i missing? Please need help asap.
Hi, I am using this online solution for Grideview Drag and Drop asp.net web forms (https://www.aspsnippets.com/Articles/Reorder-GridView-Rows-Drag-and-Drop-ordering-of-GridView-Rows-using-jQuery-in-ASPNet.aspx). Everything works fine but now I need help updating the database table with additional fields. For example: I need to update the table of who dragged and dropped the row. I added the "UpdateBy" field to my update statement , it works, but it updates every row with the value not the one row that was dropped. What am i missing? Please need help asap.
Private Sub BindGrid()
Dim query As String = "SELECT [id], [DisplayOrder], [STUDY], [PATIENT],[WAIT_TIME],[USER_ID],[UpdateBy] FROM [Radio_queue4] " +
"order by DisplayOrder asc"
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand(query)
Using sda As New SqlDataAdapter()
cmd.CommandType = CommandType.Text
cmd.Connection = con
sda.SelectCommand = cmd
Using dt As New DataTable()
sda.Fill(dt)
grid.DataSource = dt
grid.DataBind()
End Using
End Using
End Using
End Using
End Sub
Protected Sub UpdatePreference(sender As Object, e As EventArgs)
Dim ids As Integer() = (From p In Request.Form("id1").Split(",")
Select Integer.Parse(p)).ToArray()
Dim DisplayOrder As Integer = 1
For Each id As Integer In ids
Me.UpdatePreference(id, DisplayOrder)
DisplayOrder += 1
Next
Response.Redirect(Request.Url.AbsoluteUri)
End Sub
Private Sub UpdatePreference(id As Integer, DisplayOrder As Integer)
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As New System.Data.SqlClient.SqlConnection(constr)
Using cmd As New SqlCommand("UPDATE Radio_queue4 SET DisplayOrder = @DisplayOrder, UpdateBy = @UpdateBy WHERE id = @id")
Using sda As New SqlDataAdapter()
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("@id", id)
cmd.Parameters.AddWithValue("@DisplayOrder", DisplayOrder)
cmd.Parameters.AddWithValue("@UpdateBy", "TestUser")
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
End Using
End Sub
Private Sub form1_Load(sender As Object, e As EventArgs) Handles form1.Load
If Not IsPostBack Then
Me.BindGrid()
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad I could help.
ASKER