For i = 0 To GridView1.Rows.Count - 1
If DirectCast(GridView1.Rows(i).FindControl("chk"), CheckBox).Checked() Then
Dim row As GridViewRow = GridView1.Rows(i)
cmd = New SqlCommand
cmd.Connection = conn
cmd.CommandText = "INSERT INTO Z_User_MenuVSGroup(menu_id, menu_name, menu_parent_id, menu_url, group_code) Values(@menuid,@menuname,@menuparentid,@menuurl,@groupcode)"
cmd.CommandType = CommandType.Text
conn.Open()
Try
cmd.Parameters.AddWithValue("@menuid", row.Cells(1).Text)
cmd.Parameters.AddWithValue("@menuname", row.Cells(2).Text)
cmd.Parameters.AddWithValue("@menuparentid", row.Cells(4).Text)
cmd.Parameters.AddWithValue("@menuurl", row.Cells(5).Text)
cmd.Parameters.AddWithValue("@groupcode", UCase(Me.cboDesigCode.SelectedValue))
cmd.ExecuteNonQuery()
Catch ex As Exception
Finally
cmd = Nothing
conn.Close()
End Try
End If
Next