Solved

VB.net combo box

Posted on 2014-07-23
2
270 Views
Last Modified: 2014-08-30
Here is a code segment that runs successfully
In the part that is enclosed with ************************
I have a check box
When that box is checked we want to display a combo box that retrieves data from fccp.Resller.CompanyName
Could you help with the code to accomplish this?
Thanks in advance

Imports System.Data.SqlClient

Public Class CWActivityReport
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub ButtonRunReport_Click(sender As Object, e As EventArgs) Handles ButtonRunReport.Click
        GetAddedClients()
        GetDeletedClients()
        UpdatePanelReport.Update()

    End Sub

    Private Sub GetAddedClients()
        Dim FCCP_SQL As SqlConnection = Nothing

        Dim FCCP_DATAADAPTOR As SqlDataAdapter = Nothing
        Dim dt As DataTable = Nothing

        Try
            FCCP_SQL = New SqlConnection
            FCCP_SQL.ConnectionString = ConfigurationManager.ConnectionStrings("FCCP_SQL").ConnectionString
            FCCP_DATAADAPTOR = New SqlDataAdapter
            dt = New DataTable
            'FCCP_DATAADAPTOR.SelectCommand = New SqlCommand("SELECT fccp_Reseller.CompanyName AS PartnerCompanyName, fccp_ResellerClients.CreatedDateTime, fccp_ResellerClients.CompanyName AS ClientCompanyName, fccp_ResellerClients.ClientCode AS CompanyCode FROM fccp_ResellerClients INNER JOIN fccp_Reseller ON fccp_ResellerClients.ResellerID = fccp_Reseller.ID WHERE (fccp_ResellerClients.Deleted = 0) AND (fccp_ResellerClients.CreatedDateTime Between @StartDate AND @EndDate) AND NOT fccp_Reseller.ResellerCode='f44' ORDER BY PartnerCompanyName, fccp_ResellerClients.CreatedDateTime ASC", FCCP_SQL)
            FCCP_DATAADAPTOR.SelectCommand = New SqlCommand("SELECT fccp_Reseller.CompanyName AS PartnerCompanyName, fccp_ResellerClients.CreatedDateTime, fccp_ResellerClients.CompanyName AS ClientCompanyName, fccp_ResellerClients.ClientCode AS CompanyCode FROM fccp_ResellerClients INNER JOIN fccp_Reseller ON fccp_ResellerClients.ResellerID = fccp_Reseller.ID WHERE (fccp_ResellerClients.CreatedDateTime Between @StartDate AND @EndDate) AND NOT fccp_Reseller.ResellerCode='f44' ORDER BY PartnerCompanyName, fccp_ResellerClients.CreatedDateTime ASC", FCCP_SQL)
            FCCP_DATAADAPTOR.SelectCommand.Parameters.AddWithValue("@StartDate", TextBoxStartDate.Text + " " + "0:00:00 AM")
            FCCP_DATAADAPTOR.SelectCommand.Parameters.AddWithValue("@EndDate", TextBoxEndDate.Text + " " + "11:59:59 PM")

            dt.Clear()
            FCCP_SQL.Open()
            FCCP_DATAADAPTOR.Fill(dt)

            RepeaterCreatedClients.DataSource = dt
            RepeaterCreatedClients.DataBind()

        Catch ex As Exception
            Debug.WriteLine(ex.Message)
        Finally
            If Not FCCP_SQL Is Nothing Then FCCP_SQL.Dispose()
            If Not FCCP_DATAADAPTOR Is Nothing Then FCCP_DATAADAPTOR.Dispose()
            If Not dt Is Nothing Then dt.Dispose()
        End Try
    End Sub

    Private Sub GetDeletedClients()
        Dim FCCP_SQL As SqlConnection = Nothing

        Dim FCCP_DATAADAPTOR As SqlDataAdapter = Nothing
        Dim dt As DataTable = Nothing

        Try
            FCCP_SQL = New SqlConnection
            FCCP_SQL.ConnectionString = ConfigurationManager.ConnectionStrings("FCCP_SQL").ConnectionString
            FCCP_DATAADAPTOR = New SqlDataAdapter
            dt = New DataTable
            FCCP_DATAADAPTOR.SelectCommand = New SqlCommand("SELECT fccp_Reseller.CompanyName AS PartnerCompanyName, fccp_ResellerClients.DeletedDateTime, fccp_ResellerClients.CompanyName AS ClientCompanyName, fccp_ResellerClients.ClientCode AS CompanyCode FROM fccp_ResellerClients INNER JOIN fccp_Reseller ON fccp_ResellerClients.ResellerID = fccp_Reseller.ID WHERE (fccp_ResellerClients.DeletedDateTime Between @StartDate AND @EndDate) AND NOT fccp_Reseller.ResellerCode='f44' ORDER BY PartnerCompanyName, fccp_ResellerClients.CreatedDateTime ASC", FCCP_SQL)
            'FCCP_DATAADAPTOR.SelectCommand = New SqlCommand("SELECT fccp_Reseller.CompanyName AS PartnerCompanyName, fccp_ResellerClients.DeletedDateTime, fccp_ResellerClients.CompanyName AS ClientCompanyName, fccp_ResellerClients.ClientCode AS CompanyCode FROM fccp_ResellerClients INNER JOIN fccp_Reseller ON fccp_ResellerClients.ResellerID = fccp_Reseller.ID WHERE (fccp_ResellerClients.Deleted = 1) AND (fccp_ResellerClients.DeletedDateTime Between @StartDate AND @EndDate) AND NOT fccp_Reseller.ResellerCode='f44' ORDER BY PartnerCompanyName, fccp_ResellerClients.CreatedDateTime ASC", FCCP_SQL)
            FCCP_DATAADAPTOR.SelectCommand.Parameters.AddWithValue("@StartDate", TextBoxStartDate.Text + " " + "0:00:00 AM")
            FCCP_DATAADAPTOR.SelectCommand.Parameters.AddWithValue("@EndDate", TextBoxEndDate.Text + " " + "11:59:59 PM")

            dt.Clear()
            FCCP_SQL.Open()
            FCCP_DATAADAPTOR.Fill(dt)

            RepeaterDeletedClients.DataSource = dt
            RepeaterDeletedClients.DataBind()

        Catch ex As Exception
            Debug.WriteLine(ex.Message)
        Finally
            If Not FCCP_SQL Is Nothing Then FCCP_SQL.Dispose()
            If Not FCCP_DATAADAPTOR Is Nothing Then FCCP_DATAADAPTOR.Dispose()
            If Not dt Is Nothing Then dt.Dispose()
        End Try
    End Sub

    Protected Sub SIP_CheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles SIP_CheckBox.CheckedChanged
        Dim FCCP_SQL As SqlConnection = Nothing

        Dim FCCP_DATAADAPTOR As SqlDataAdapter = Nothing
        Dim dt As DataTable = Nothing
***************************************************************
        If SIP_CheckBox.Checked Then
            MsgBox("SIP check box was selected")

        End If
    End Sub
***************************************************************

End Class

Open in new window

0
Comment
Question by:tesla764
2 Comments
 
LVL 9

Accepted Solution

by:
dustock earned 500 total points
Comment Utility
Is there a query that you are going to run when the checkbox is checked?  Once you have your query executed and you've filled your datatable, you need to set it as the DataSource for your combobox.

comboBox1.DataSource = dt
comboBox1.DisplayMember = "fieldName"
'If you have an ID you want associated with the display name add the line below
comboBox1.ValueMember = "fieldName"

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now