Réponse acceptée !
salut,
dans le datagrid tu peux définir
DataKeyField="
id" (id étant la primary key)
ensuite lors du postback tu peux récupérer les checkbox checkées de lap manière suivante (événement lors d'un click sur un hyperlink ici):
Private Sub lbtnConcat_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnConcat.Click
Dim dgItem As DataGridItem
Dim chkItem As System.Web.UI.WebControls.CheckBox
Dim sIds As String
Dim iCounter As Integer = 0
For Each dgItem In Me.dgArticles.Items
Try
'chkToConcat et l'id de mes checkbox
chkItem = CType(dgItem.FindControl("chkToConcat"), System.Web.UI.WebControls.CheckBox)
If chkItem.Checked Then
iCounter = iCounter + 1
If sIds = "" Then
'DataKeys utilise la propriété DataKeyField.
'dgArticles.DataKeys(dgItem.ItemIndex).ToString() me retourne la valeur "id" (champs de la base de données) de l'item courant
sIds = sIds & dgArticles.DataKeys(dgItem.ItemIndex).ToString()
Else
sIds = sIds & "," & dgArticles.DataKeys(dgItem.ItemIndex).ToString()
End If
End If
Catch ex As Exception
Throw
End Try
Next
End Sub
yopyop