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
|
Partial Class Module_AntreJeu_ListePub
Inherits System.Web.UI.UserControl
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
With sdsListePub
If Request.QueryString("categ") = "" Then
.SelectCommand = "EXEC dbo.ANTRE_ListePublicite 0"
Else
.SelectCommand = "EXEC dbo.ANTRE_ListePublicite " & Request.QueryString("categ")
End If
End With
Dim bfPub As New TemplateField
With bfPub
.ItemTemplate = New TplListePubItem(DataControlRowType.DataRow)
End With
With gvListePub
.AutoGenerateColumns = False
.AllowPaging = True
.AllowSorting = False
.Columns.Add(bfPub)
.PageSize = 10
.EmptyDataText = "Pas de publicité pour la demande en cours"
With .PagerSettings
.Mode = PagerButtons.Numeric
.Position = PagerPosition.Bottom
End With
.CssClass = "LISTEPUB_GVGene"
.AlternatingRowStyle.CssClass = "LISTEPUB_GVAlternateRow"
.EditRowStyle.CssClass = "LISTEPUB_GVEditRow"
.FooterStyle.CssClass = "LISTEPUB_GVFooter"
.HeaderStyle.CssClass = "LISTEPUB_GVHeader"
.PagerStyle.CssClass = "LISTEPUB_GVPager"
.SelectedRowStyle.CssClass = "LISTEPUB_GVSelectedRow"
.RowStyle.CssClass = "LISTEPUB_GVRow"
End With
End Sub
Protected Sub gvListePub_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvListePub.PageIndexChanging
gvListePub.PageIndex = e.NewPageIndex
gvListePub.DataBind()
End Sub
End Class
Public Class TplListePubItem
Implements ITemplate
Private templateType As DataControlRowType
Sub New(ByVal type As DataControlRowType)
templateType = type
End Sub
Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn
Select Case templateType
Case DataControlRowType.DataRow
Dim lblTitre, lbldescription As New Label
Dim litScript As New Literal
AddHandler lblTitre.DataBinding, AddressOf lblTitre_dataBind
AddHandler lbldescription.DataBinding, AddressOf lblDescription_dataBind
AddHandler litScript.DataBinding, AddressOf litScript_dataBind
Dim divpub, divSeparation As New HtmlControls.HtmlGenericControl("div")
divSeparation.Attributes.Add("class", "CadreDivPubSep")
With divpub
With .Controls
.Add(lblTitre)
.Add(New LiteralControl("<br />"))
.Add(lbldescription)
.Add(New LiteralControl("<br />"))
.Add(litScript)
.Add(New LiteralControl("<br /><br /><br />"))
End With
.Attributes.Add("class", "CadreDivPub")
End With
With container.Controls
.Add(divpub)
.Add(divSeparation)
End With
Case Else
End Select
End Sub
Private Sub lblTitre_dataBind(ByVal sender As Object, ByVal e As EventArgs)
Dim l As Label = CType(sender, Label)
Dim row As GridViewRow = CType(l.NamingContainer, GridViewRow)
With l
.Text = DataBinder.Eval(row.DataItem, "TitrePub")
End With
End Sub
Private Sub lblDescription_dataBind(ByVal sender As Object, ByVal e As EventArgs)
Dim l As Label = CType(sender, Label)
Dim row As GridViewRow = CType(l.NamingContainer, GridViewRow)
With l
.Text = DataBinder.Eval(row.DataItem, "DescriptionPub")
End With
End Sub
Private Sub litScript_dataBind(ByVal sender As Object, ByVal e As EventArgs)
Dim lit As Literal = CType(sender, Literal)
Dim row As GridViewRow = CType(lit.NamingContainer, GridViewRow)
With lit
.Text = DataBinder.Eval(row.DataItem, "ScriptPub")
End With
End Sub
End Class |
Partager