Solved Bind data to GridView then check boxes

Posted on 2011-10-05
Last Modified: 2012-06-27

I have a SQL table that I am binding to a GridView in 4.
The table has and ID column, a column with a text question and then 5 bit
columns. The bit columns come up as check boxes on my page.
I want the user to be able to check one of the boxes and have it save to the table
but this is not possible.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' This example uses Microsoft SQL Server and connects
        ' to the Northwind sample database. The data source needs
        ' to be bound to the GridView control only when the 
        ' page is first loaded. Thereafter, the values are
        ' stored in view state.                      
        If Not IsPostBack Then

            Dim queryString2 As String = _
  "Select * From Questions"

            ' Run the query and bind the resulting DataSet
            ' to the GridView control.
            Dim ds2 As DataSet = GetData(queryString2)
            If (ds.Tables.Count > 0) Then

                Me.GridView2.DataSource = ds2


                'Me.Label_Error1.Text = "Unable to connect to the database. " & Err.Description

            End If

        End If

    End Sub

Open in new window

Question by:murbro
    LVL 4

    Accepted Solution


    To save the checkbox state to the database, while saving the data, loop through the gridview rows and get the checkbox check status and set the booleam flags accordingly. On sending these data to database it can be saved to database.
    LVL 83

    Expert Comment

    >I want the user to be able to check one of the boxes and have it save to the table
    but this is not possible.

    Have you tried? Does it save changes to other fields?

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    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

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    This video discusses moving either the default database or any database to a new volume.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 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

    15 Experts available now in Live!

    Get 1:1 Help Now