l'ho fatto così, se ci sono metodi più smart e meno dispendiosi in termini di righe di codice ben vengano i suggerimenti... mi secca non poco il dover fare un postback ad ogni spunta su un checkbox ma non vedo alternative
codice:
'***questo sul rowdatabound setta lo stato del checkbox quando mostro i dati impaginati
Protected Sub gridview1_rowdatabound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim chk As CheckBox, gvr As GridViewRow = e.Row
Dim dv = gvr.DataItem
If Not IsNothing(dv) Then
If InStr("," & Session("selezionate"), "," & dv.item("conto").ToString()) > 0 Then
chk = gvr.Cells(0).FindControl("chkSelected")
chk.Checked = True
End If
End If
End Sub
'*** sul postback modifico la session a seconda dello stato del checkbox
Protected Sub CHK_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
'mette in session le anagrafiche conto selezionate
Dim checkbox As CheckBox = sender
Dim anagrafica = checkbox.Attributes("dato").ToString.ToString
If checkbox.Checked = True Then
Session("selezionate") &= anagrafica & ","
Else
Session("selezionate") = Replace("," & Session("selezionate"), "," & anagrafica & ",", ",")
Session("selezionate") = Replace(Session("selezionate"), ",,", "")
End If
End Sub