0

画像がないときにリピーターに「NO IMAGE」というテキストを含む画像を配置したい。これを達成するには、どのような変更を加える必要がありますか? Repeater データソースが、ルート ディレクトリの IMAGE フォルダー内の画像を指すようにします。

マイページロード

If Not IsPostBack Then

                Dim sBasePath As String = System.Web.HttpContext.Current.Request.ServerVariables("APPL_PHYSICAL_PATH")
                If sBasePath.EndsWith("\") Then
                    sBasePath = sBasePath.Substring(0, sBasePath.Length - 1)
                End If

                sBasePath = sBasePath & "\" & "pics" & "\" & lblID.Text

                Dim oList As New System.Collections.Generic.List(Of String)()

                For Each s As String In System.IO.Directory.GetFiles(sBasePath, "*_logo.*")

                    'We could do some filtering for example only adding .jpg or something 
                    oList.Add(System.IO.Path.GetFileName(s))

                Next

                If oList.Count = 0 Then

                  //I must do something here

                    repImages.DataSource = ??????
                    repImages.DataBind()

                Else

                    repImages.DataSource = oList
                    repImages.DataBind()

                End If


            End If
4

1 に答える 1

1

画像がない場合は、「No Images」というテキストを含む画像をロードして oList に追加し、repImages.DataSource に割り当てることができます。

If Not IsPostBack Then

            Dim sBasePath As String = System.Web.HttpContext.Current.Request.ServerVariables("APPL_PHYSICAL_PATH")
            If sBasePath.EndsWith("\") Then
                sBasePath = sBasePath.Substring(0, sBasePath.Length - 1)
            End If

            sBasePath = sBasePath & "\" & "pics" & "\" & lblID.Text

            Dim oList As New System.Collections.Generic.List(Of String)()

            For Each s As String In System.IO.Directory.GetFiles(sBasePath, "*_logo.*")

                'We could do some filtering for example only adding .jpg or something 
                oList.Add(System.IO.Path.GetFileName(s))

            Next

            If oList.Count = 0 Then

              oList.Add("Path to a image with no image text")

            End If

   repImages.DataSource = oList
                repImages.DataBind()


        End If
于 2009-04-19T09:30:18.607 に答える