Hi Guys,
I've got a code that basically storing data from several controls, one of the control is GridView. when I "Submit" I get all rows from GridView and I need only the selected rows..
I've tried to use: str = GridView1.SelectedRow.Cells(1).Text
but it gives me an error when I run the application.
Can you help please? Thanks!
Protected Sub SaveOrder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveOrder.Click
Dim str As String
For i As Integer = 0 To GridView1.Rows.Count - 1
Dim row As GridViewRow = GridView1.Rows(0)
Dim isChecked As Boolean = DirectCast(row.FindControl("CheckBox1"), CheckBox).Checked
If isChecked Then
str = GridView1.Rows(i).Cells(1).Text
End If
Dim strUID As String
strUID = Session.Item("uid").ToString
Dim cmd As New SqlCommand("INSERT INTO fo_reports (order_date,code,dept_id,id_number,sug,uid)VALUES('" & Calendar1.SelectedDate & "','" & DropDownList1.SelectedItem.Text & "','" & DropDownList2.SelectedItem.Text & "','" & str.ToString & "','" & DropDownList3.SelectedItem.Text & "','" & strUID & "')", New SqlConnection(strConn))
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
Next
Response.Redirect("order.aspx")
End Sub