Quantcast
Viewing all articles
Browse latest Browse all 12583

How to uncheck the checkboxlist after checking the box (asp.net vb.net)

Hi there 

i would like to uncheck the checkboxlist after choosing the boxes and saving them to database , literally these boxes will be disable .

i also attached my code below , thanks in advance

table Seat : ID (int ) PK , SeatNumber (varchar(50) )null


thecheckboxlist ( 'http://social.msdn.microsoft.com/Forums/getfile/378568)


here is my code

Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration

Partial Class test12
    Inherits System.Web.UI.Page
    Dim con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString2").ToString())

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If con.State = ConnectionState.Closed Then
            con.Open()
        End If
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim str As [String] = ""
        For i As Integer = 0 To chkeducation.Items.Count - 1

            If chkeducation.Items(i).Selected Then

                If str = "" Then
                    str = chkeducation.Items(i).Text
                Else

                    str += "," + chkeducation.Items(i).Text

                End If
            End If
            If chkeducation.Items(i).Selected = False Then
                chkeducation.Enabled = True
            Else
                chkeducation.Enabled = False
            End If
        Next

        Dim cmd As New SqlCommand("Insert into Seat(SeatNumber) values('" & str & "')", con)
        cmd.ExecuteNonQuery()
        clear()
        con.Close()

       
    End Sub
    Public Sub clear()
        chkeducation.SelectedIndex = -1
    End Sub
    Protected Sub CheckBoxList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkeducation.SelectedIndexChanged

    End Sub
End Class


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>