1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| Imports Wib_screenMessages
Partial Class DisplayPictures_Zooffy
Inherits System.Web.UI.Page
Public pLang As String
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Dim bf As BoundField = Nothing
Dim hf As HyperLinkField = Nothing
Dim apercu As New TemplateField
With apercu
.ItemTemplate = New TemplatePopup(DataControlRowType.DataRow, "Id", "Apercu")
.HeaderTemplate = New TemplatePopup(DataControlRowType.Header, "Apercu", "Apercu")
End With
pLang = Request.QueryString("Lang")
If Not Page.IsPostBack Then
bf = New BoundField
bf.HeaderText = getWibMsg(796, "Sort", pLang)
bf.DataField = "idSupplier"
bf.SortExpression = "idSupplier"
Logos.Columns.Add(bf)
bf.ItemStyle.Width = New Unit("140", UnitType.Pixel)
bf = New BoundField
bf.HeaderText = getWibMsg(797, "Sort", pLang)
bf.DataField = "id"
bf.SortExpression = "id"
Logos.Columns.Add(bf)
bf.ItemStyle.Width = New Unit("140", UnitType.Pixel)
apercu = New TemplateField
apercu.HeaderText = getWibMsg(798, "Sort", pLang)
Logos.Columns.Add(apercu)
End If
End Sub
Public Class TemplatePopup
Implements ITemplate
Private templateType As DataControlRowType
Private columnName As String 'le nom de la colonne de la source de données
Private controleName As String 'le nom du contrôle à mettre dans la colonne
Sub New(ByVal type As DataControlRowType, ByVal colname As String, ByVal ctrlName As String)
templateType = type
columnName = colname
controleName = ctrlName
End Sub
Sub InstantiateIn(ByVal container As System.Web.UI.Control) _
Implements ITemplate.InstantiateIn
Select Case templateType
Case DataControlRowType.Header
Dim lc As New Literal
lc.Text = "<b>" & columnName & "</b>"
container.Controls.Add(lc)
Case DataControlRowType.DataRow
Select Case controleName
Case "Apercu"
Dim hl As New HyperLink
AddHandler hl.DataBinding, AddressOf hl_DataBinding
container.Controls.Add(hl)
Case "Actif"
Dim ib As New LinkButton
AddHandler ib.DataBinding, AddressOf ib_DataBinding
container.Controls.Add(ib)
Case Else
End Select
Case Else
' Insert code to handle unexpected values.
End Select
End Sub
Private Sub hl_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
Dim l As HyperLink = CType(sender, HyperLink)
Dim row As GridViewRow = CType(l.NamingContainer, GridViewRow)
l.Text = DataBinder.Eval(row.DataItem, "Id").ToString()
l.ID = "hlCamp" & DataBinder.Eval(row.DataItem, "Id").ToString()
End Sub
Private Sub ib_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
Dim l As LinkButton = CType(sender, LinkButton)
Dim row As GridViewRow = CType(l.NamingContainer, GridViewRow)
l.ID = "ibActif" & DataBinder.Eval(row.DataItem, "Id").ToString()
l.Enabled = True
l.CommandName = "chgActif"
End Sub
End Class
Protected Sub Logos_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles Logos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lnk As HyperLink = CType(e.Row.FindControl("hlCamp" & CType(DataBinder.Eval(e.Row, "DataItem.Id"), String)), HyperLink)
With lnk
.NavigateUrl = "~/DisplayPictures/ShowPicture2.aspx?id=2"
.ImageUrl = "~/DisplayPictures/Mvu.jpg"
End With
End If
End If
End Sub
End Class |