Avatar of Murray Brown
Murray Brown
Flag 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

ASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
Murray Brown

8/22/2022 - Mon