Hi
I have an issue
I have 2 Checkbox list populated the data from database. It is fine
One is Industry, Another one is Department
If i select multiple selection from checkbox list,
i need load data into grid view control based on selection.
<div class="col-lg-3">
<asp:Label ID="Label1" runat="server" Text="Industry" ForeColor="Red" Font-Bold="true"></asp:Label>
<div style="width:230px;height:300px; padding:1px; overflow:auto; border: 1px solid #ccc;">
<asp:CheckBoxList ID="chkIndustry" runat="server" CssClass="form-control-lst" RepeatLayout="table"
RepeatColumns="1" RepeatDirection="vertical"></asp:CheckBoxList>
</div>
</div>
<div class="col-lg-3">
<asp:Label ID="Label2" runat="server" Text="Department" ForeColor="Red" Font-Bold="true"></asp:Label>
<div style="width:230px;height:300px; padding:1px; overflow:auto; border: 1px solid #ccc;">
<asp:CheckBoxList ID="chkDepartment" runat="server" CssClass="form-control-lst" RepeatLayout="table"
RepeatColumns="1" RepeatDirection="vertical"></asp:CheckBoxList>
</div>
</div>
<asp:GridView ID="GridView1" runat="server" CssClass="gridview" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None"
BorderWidth="1px" CellPadding="3" PageSize="15">
<Columns>
<asp:CommandField ShowSelectButton="True">
<ItemStyle Width="50px" />
</asp:CommandField>
<asp:TemplateField ShowHeader="False">
<HeaderTemplate>
<asp:CheckBox ID="allchk" runat="server" />
</HeaderTemplate>
<ItemTemplate><asp:CheckBox ID="chk" runat="server" /></ItemTemplate>
<ItemStyle Width="10px" />
</asp:TemplateField>
<asp:BoundField DataField="Code" HeaderText="Code" />
<asp:BoundField DataField="name" HeaderText="CoName" />
<asp:BoundField DataField="industry" HeaderText="Industry" />
<asp:BoundField DataField="NAMED" HeaderText="Delegate" />
<asp:BoundField DataField="status" HeaderText="Status" />
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
Function
Public Function LoadParamDetails_CHK(chkList As CheckBoxList, strParamHead As String) As String
LoadParamDetails_CHK = String.Empty
Dim sConstr As String = ConfigurationManager.ConnectionStrings("ConnectString").ConnectionString
Dim Conn As New SqlConnection(sConstr)
Using Conn
Dim command As New SqlCommand("Select * from Parameter where paramhead ='" & strParamHead & "' order by paramdetails", Conn)
Dim da As New SqlDataAdapter()
Dim dt As New DataTable()
command.CommandType = CommandType.Text
Conn.Open()
da.SelectCommand = command
da.Fill(dt)
chkList.DataSource = dt
chkList.DataValueField = "id"
chkList.DataTextField = "paramdetails"
chkList.DataBind()
End Using
Conn = Nothing
Return LoadParamDetails_CHK
End Function
Call Function
LoadParamDetails_CHK(Me.chkIndustry, "industry")
LoadParamDetails_CHK(Me.chkDepartment, "department")
I used try this code. It is populated only one industry even though i have selected Multiple industry and also I am blur how to add selected department into this code from Department checkbox list
Private Sub LoadSelectDelegate()
For i As Integer = 0 To Me.chkIndustry.Items.Count - 1
If Me.chkIndustry.Items(i).Selected = True Then
Dim query As String = "select * from vw_Client_HD where industry = '" + Me.chkIndustry.Items(i).Text + "'"
Dim dt As DataTable = GetData(query)
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
End If
Next
Pls advice me
Thank you
Maideen