This is a migrated thread and some comments may be shown as answers.

which item was checked/unchecked in checkboxlist

1 Answer 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mydatafactory
Top achievements
Rank 1
Mydatafactory asked on 16 Oct 2008, 11:37 AM

In a grid I have a checkboxlist. I can retrieve the selectedvalue, but, in order to insert/update/delete the selectedvalue in a datatable, I would like to retrieve which item of a checkboxlist has been checked or unchecked. I think it's a tiny issue, but I keep struggling with it, despite my search on the forum and the internet.

    Protected Sub chkTasks_CheckedChanged(ByVal sender As ObjectByVal e As System.EventArgs)  
        Dim Today As Date 
        Today = Now()  
 
        Dim chkBox As CheckBoxList = CType(sender, CheckBoxList)  
        Dim myPanel As Panel = CType(chkBox.Parent, Panel)  
        Dim dataItem As GridDataItem = CType(myPanel.NamingContainer, GridDataItem)  
        If chkBox.SelectedValue <> "" Then 
            dataItem("FileName").Style("color") = "orange" 
            Dim file As Integer = dataItem("FileId").Text  
            Dim Task As Integer = chkBox.SelectedValue  
            Dim Ext As RadComboBox = TryCast(dataItem.FindControl("cmbxExtension"), RadComboBox)  
            Dim Extension As Integer = Int32.Parse(Ext.SelectedValue)  
 
            Dim strSQL As String = _  
                        "INSERT INTO tblBewerkingToFile " & _  
                        "(FileId, BewerkingId, ExtensionFormat) " & _  
                        "VALUES " & _  
                        "(@FileId, @BewerkingId, @ExtensionFormat)" 
            Dim Command As New SqlCommand(strSQL)  
 
            Command.Parameters.AddWithValue("@FileId", file)  
            Command.Parameters.AddWithValue("@BewerkingId", Task)  
            Command.Parameters.AddWithValue("@ExtensionFormat", Extension)  
            DBPortal.Execute(Command)  
 
        End If 
 
        Dim previewControl As Control = FindPageControl("previewControl")  
 
        Dim NoResults As Label = previewControl.FindControl("lblNoChoice")  
        NoResults.Visible = False 
 
        Dim ValidResults As Repeater = previewControl.FindControl("rpValidBewerking")  
        ValidResults.Visible = True 
    End Sub 
 

1 Answer, 1 is accepted

Sort by
0
Mydatafactory
Top achievements
Rank 1
answered on 16 Oct 2008, 01:27 PM
I've solved it myself after a walk with my dog. A little bit of fresh air makes the mind clearer.......
Tags
Grid
Asked by
Mydatafactory
Top achievements
Rank 1
Answers by
Mydatafactory
Top achievements
Rank 1
Share this question
or