Look my problem :
PAGE ASPX :
#Region " - Page_Load - "
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
monStyle.Text = Session("style")
bindData()
Session("selectionligne") = -1
End If
End Sub
#End Region
#Region " - bindData - "
Public Sub bindData()
daAdminProspects.Fill(Bts1)
dgAdminProspects.DataSource = myDataview
dgAdminProspects.DataBind()
End Sub
#End Region
#Region " - ItemDataBound - "
Private Sub dgClient_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgAdminProspects.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim imgDelete As ImageButton =
CType(e.Item.FindControl("imgDelete"), ImageButton)
CreateConfirmBox(imgDelete, "Attention, merci de confirmer
la suppression.")
End If
End Sub
#End Region
#Region " - ItemCommand - "
Private Sub dgAdminProspects_ItemCommand(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgAdminProspects.ItemCommand
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
If e.CommandName = "Select" Then
dgAdminProspects.EditItemIndex = -1
bindData()
End If
End If
End Sub
#End Region
#Region " - SelectedIndexChanged - "
Private Sub dgAdminProspects_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
dgAdminProspects.SelectedIndexChanged
If dgAdminProspects.SelectedIndex = Session("selectionLigne")
Then
dgAdminProspects.SelectedIndex = -1
Session("selectionLigne") = -1
bindData()
Else
'Pas le meme => initialise la session("selectionLigne")
Session("selectionLigne") = dgAdminProspects.SelectedIndex
End If
End Sub
#End Region
#Region " - PreRender - "
Private Sub dgAdminProspects_PreRender(ByVal sender As Object, ByVal
e As System.EventArgs) Handles dgAdminProspects.PreRender
If dgAdminProspects.SelectedIndex > -1 Then
Dim oDGItem As New DataGridItem(0, 0, ListItemType.Item)
Dim oCell As New TableCell
oCell.HorizontalAlign = HorizontalAlign.Left
oCell.ColumnSpan = dgAdminProspects.Columns.Count
oDGItem.Cells.Add(oCell)
Dim myUC As ficheProspects =
CType(Page.LoadControl("ficheProspects.ascx"), ficheProspects)
myUC.monId =
CType(dgAdminProspects.DataKeys(dgAdminProspects.SelectedIndex),
Integer)
'Vérifie si la couleur est alternative
If dgAdminProspects.SelectedIndex Mod 2 <> 0 Then
myUC.backcouleur =
CType(dgAdminProspects.AlternatingItemStyle.BackColor,
System.Drawing.Color)
oCell.BackColor =
dgAdminProspects.AlternatingItemStyle.BackColor
End If
oCell.Controls.Add(myUC)
dgAdminProspects.Controls(0).Controls.AddAt(dgAdminProspects.SelectedInd
ex + 3, oDGItem)
End If
End Sub
#End Region
---------------------------------------------
USERCONTROL : i have a panel, a table, and a button
'Variable public pour communiquer avec la page .aspx
Private _backcouleur As System.Drawing.Color
Public Property backcouleur() As System.Drawing.Color
Get
Return _backcouleur
End Get
Set(ByVal Value As System.Drawing.Color)
_backcouleur = Value
End Set
End Property
Private _monId As Integer
Public Property monId() As Integer
Get
Return _monId
End Get
Set(ByVal Value As Integer)
_monId = Value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Changer le background des panel
panelProspects.BackColor = backcouleur
panelProspectsUpdate.BackColor = backcouleur
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Write("TEST")
End Sub