HOME > .NET Framework > Forum > ช่วยทีครับมัน error Index was out of range. Must be non-negative and less than the size of the collection Parameter name:index
ช่วยทีครับมัน error Index was out of range. Must be non-negative and less than the size of the collection Parameter name:index
Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
Dim a As String = CStr(GridView1.DataKeys.Item(e.NewEditIndex).Value)
If GridView1.RowHeaderColumn = "ซื้อ" Then
Dim now As Date = Date.Now.ToString("yyyy-MM-dd")
Dim d As String = now
Dim stsql As String = "insert into get_day(Users,p_id,status,send_day) values('" & Session("user") & "','" & a & "','ซื้อ','" & d & "')"
' Dim susql As String = "update get_day set Users='',p_id='',status='' where send_day='" & now & "'"
Dim obcmd As New SqlCommand(stsql, con)
con.Open()
obcmd.ExecuteNonQuery()
con.Close()
binddata()
Response.Redirect("OK.aspx")
Else
Dim now As Date = Date.Now.ToString("yyyy-MM-dd")
Dim d As String = now
Dim stsql As String = "insert into get_day(Users,p_id,status,send_day) values('" & Session("user") & "','" & a & "','จอง','" & d & "')"
' Dim susql As String = "update get_day set Users='',p_id='',status='' where send_day='" & now & "'"
Dim obcmd As New SqlCommand(stsql, con)
con.Open()
obcmd.ExecuteNonQuery()
con.Close()
binddata()
Response.Redirect("OK.aspx")
End If
End Sub