Imports Telerik.Web.UI

Partial Class _Default
    Inherits System.Web.UI.Page
    Private Shared Id As Integer
    Public Shared Property ImageId() As String
        Get
            Return Id
        End Get
        Set(ByVal value As String)

            Id = value
        End Set
    End Property

    Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
        If TypeOf e.Item Is GridDataItem Then
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
            Dim img As New Image()
            img.ID = "Image1"
            Dim Id As String = CType(item("id_film").FindControl("hidden"), HiddenField).Value
            If (Id = ImageId) Then
                img.ImageUrl = "~/Images/" + "1" + ".png"
            Else
                img.ImageUrl = "~/Images/" + Id + ".png"

            End If
            item("id_film").Controls.Add(img)
        End If
    End Sub

    Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        Dim table As New DataTable()
        table.Columns.Add("id_film")
        Dim i As Integer = 1
        While i < 4
            table.Rows.Add(i)
            i += 1
        End While
        RadGrid1.DataSource = table

    End Sub

    Protected Sub RadGrid1_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
        Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
        ImageId = CType(item("id_film").Parent.FindControl("hidden"), HiddenField).Value
    End Sub
End Class
