Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data Design Question
Message
From
29/04/2008 13:51:41
 
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
01313710
Message ID:
01313974
Views:
9
>>>>Select all works, as does unselect all because those cases are handled as checkbox events. I am now dealing with a scenario where if a user selects too many items I clear all selections programmatically and prompt for fewer selections, just cannot figure out how to clear the checkbox of the 'tick'.
>>>
>>>Is your Checkbox column bound to the data? If yes, how and then you update the underlying data?
>>
>>Our checkbox column is bound to a boolean column that is added to the datatable at runtime. We just loop through the table setting the column as appropriate.
>
>I'm not sure I get it. Can you show some code?
>
>In my case I have Approved field in the SQL Server table. I want to be able to Select All/Unselect All and I also want automatic update behind the scenes when I click on the checkbox in a grid.

Here is how we do it now. I didn't write this, and I'm not sure there aren't better ways to do this, but it works for now. The problem is this is a datatable that is saved to session. It can have a bunch of rows. I am looking at implementing paging in SQLServer as suggested by KG, but not there yet.
Public Sub CheckAll(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim chkTemp As New CheckBox
        Dim chkFind As New CheckBox
        Dim dsCount As New DataSet

        Try
            dsCount = DirectCast(Session("GetGridData"), DataSet)
            chkTemp = DirectCast(sender, CheckBox)
            If chkTemp.Checked Then
                If dsCount.Tables(0).Rows.Count = 0 Then
                    txtCheckAll.Value = "1"

                End If

                For Each drTemp As DataRow In dsCount.Tables(0).Rows
                    drTemp("IsSelected") = True
                    txtCheckAll.Value = "1"

                Next

            Else
                If dsCount.Tables(0).Rows.Count = 0 Then
                    txtCheckAll.Value = "0"

                End If

                For Each drTemp As DataRow In dsCount.Tables(0).Rows
                    drTemp("IsSelected") = False
                    txtCheckAll.Value = "0"

                Next

            End If

            SetSelectedItem(dgListItems.CurrentPageIndex * dgListItems.PageSize)

       Catch objEx As Exception

            Dim objExs As New HEWException(0, CInt(Session("UID")), _
            	"ArchiveList.aspx", "CheckAll", objEx, System.Reflection.Assembly.GetExecutingAssembly)
                SetErrors(objExs.ErrMsg, objExs.ErrSeverity)

                objExs = Nothing

        Finally

        End Try
        
   End Sub
        
        
Private Sub SetSelectedItem(ByVal iCount As Integer)
        Dim chkTemp As CheckBox

        Try
            Dim dsTemp As DataSet = DirectCast(Session("GetGridData"), DataSet)
            For Each dgDataGridItem As DataGridItem In dgListItems.Items
                chkTemp = DirectCast(dgDataGridItem.Cells(0).FindControl("chkSelect"), CheckBox)

                If Not (dsTemp.Tables(0).Rows(iCount)("IsSelected")) Is DBNull.Value Then
                    If CBool(dsTemp.Tables(0).Rows(iCount)("IsSelected")) = True Then
                        chkTemp.Checked = True

                    Else
                        chkTemp.Checked = False

                    End If

                End If
                iCount = iCount + 1

            Next

            Session("GetGridData") = dsTemp
       
        Catch objEx As Exception

            Dim objExs As New HEWException(0, CInt(Session("UID")), _
            "ArchiveList.aspx", "setSelectedItem", objEx, System.Reflection.Assembly.GetExecutingAssembly)
            SetErrors(objExs.ErrMsg, objExs.ErrSeverity)
            objExs = Nothing

        Finally

        End Try

    End Sub      
Previous
Reply
Map
View

Click here to load this message in the networking platform