I am working on code that when someone selects a company from a dropdownlist, the first grid of the company will display. I have checkboxes next to the grid. Where I am stuck is that I need to check one or more rows that will call a table from a database and display as a grid of reports. In that table, there is a column that shows checkboxes of what is visible in that company or not. In essence, how do I display results to a different gridview what I have checked from the previous/company gridview? Here is my code:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web.UI.WebControls
Partial Class companydropdown
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DropDownList1.Items.Add("")
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim sConstr As String = ConfigurationManager.ConnectionStrings("ds17701ConnectionString").ConnectionString
Dim Conn As New SqlConnection(sConstr)
Dim ds As New DataSet()
Dim dt As New DataTable
Dim valsql As String = ""
DropDownList2.Items.Clear()
If DropDownList1.SelectedIndex > 0 Then
valsql = "SELECT [CompanyID], [CompanyName], [MemberTypeID], [MembershipStatus], [GroupID] FROM CompanyList WHERE COMPANYID = " & DropDownList1.SelectedValue
Using Conn
Conn.Open()
Dim comm As New SqlCommand(valsql, Conn)
Dim da As New SqlDataAdapter(comm)
da.Fill(ds)
da.Fill(dt)
Conn.Close()
End Using
For i = 0 To ds.Tables(0).Rows.Count - 1
If ds.Tables(0).Rows(i).Item(3).ToString = "M" Then
DropDownList2.Items.Insert(0, "Member")
DropDownList2.Items.Insert(1, "Non-Member")
TextBox1.Text = "M"
Else
DropDownList2.Items.Insert(0, "Non-Member")
DropDownList2.Items.Insert(1, "Member")
TextBox1.Text = "NM"
End If
Next
Else
DropDownList2.Items.Clear()
DropDownList3.Items.Clear()
TextBox1.Text.ToString()
DropDownList1.Items.Clear()
End If
End Sub
Protected Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim sConstr As String = ConfigurationManager.ConnectionStrings("ds17701ConnectionString").ConnectionString
Dim Conn As New SqlConnection(sConstr)
Dim ds As New DataSet()
Dim valsql As String = ""
valsql = "SELECT * FROM [ReportList] ORDER BY [ReportID]"
Using Conn
Conn.Open()
Dim comm As New SqlCommand(valsql, Conn)
Dim da As New SqlDataAdapter(comm)
da.Fill(ds)
Conn.Close()
End Using
End Sub
End Class
What I have tried:
To set a for loop or create an array that will read what rows have been checked in gridview NOT datagridview, to output results. I have created a button that captures the checked rows.