[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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

0
Murray Brown
Asked:
Murray Brown
1 Solution
 
AnuTijiCommented:
hi

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.
0
 
CodeCruiserCommented:
>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?
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now