filter status by dropdownlist

Posted on 2008-11-04
Last Modified: 2013-12-17
I have a table that has tblcheck for active for true false in database sql server. I need to add a dropdown  that will only show actives my default on page load, dropdown will have active and inactive. so, basically on page load i will see all actives from database which value = true. how can i do that on c# on web dev.
Question by:1jaws
    LVL 18

    Accepted Solution

    what i got from your question that, you want to show database column values in a dropdownlist where some value is defined as  true.

    So lets assume the the column u want to show is cActivity and status column's name is cStatus.

        Dim myConnection As SqlConnection
        Dim oblV As New vbGlobalMethods
        Dim connStr As String = "your connection string goes here"

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

        If Page.IsPostBack = False Then

    End Sub

    Private Sub fillCmbCity()


                Dim dr As SqlDataReader
                Dim comm As SqlCommand
                myConnection = New SqlConnection(ConnStr)
                Dim sql As String
                sql = "select cActivity from tblActivity where cStatus='true' order by uCityName asc"
                comm = New SqlCommand(sql, myConnection)
                dr = comm.ExecuteReader
                While dr.Read
                End While
            Catch ex As Exception
                lblMessage.Text = ex.Message

            End Try
        End Sub
    LVL 96

    Assisted Solution

    by:Bob Learned
    You could use a DataView, with a RowFilter set to the condition from the DropDownList, and bind to the DataView.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    This video discusses moving either the default database or any database to a new volume.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    754 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

    20 Experts available now in Live!

    Get 1:1 Help Now