Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net Bind data to GridView then check boxes

Hi

I have a SQL table that I am binding to a GridView in ASP.net 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 ASP.net 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.GridView2.DataBind()

            Else

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

            End If

        End If

    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of AnuTiji
AnuTiji
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nasir Razzaq
>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?
Avatar of Murray Brown

ASKER

Thanks