2013-11-21 70 views
0

我有以下數據列表:Datalist中沒有得到必然正確

<asp:DataList ID="dlMovieImages" runat="server" RepeatDirection="Horizontal" RepeatColumns="6" 
            Width="100%"> 

            <ItemTemplate > 
             <div class="creamebox w49" id="inDiv" runat="server"> 
              <table width="95%" border="0" align="center" cellpadding="3" cellspacing="2" style="padding-top: 10px"> 
               <tr> 
               <td colspan="2" align="left" valign="top"> 
                <asp:Label ID="lblMovieName" runat="server" CssClass="NormalTextBig" Visible="false">MovieName</asp:Label>            </td> 

               </tr> 
               <tr> 

                <td align="left" colspan="2" valign="top"> 
                <asp:Image ID="imgSmall" runat="server" width="150" Height="200" Visible="false"/> 
                </td> 
               </tr> 
               <tr> 
               <td colspan="2" align="left" valign="top"> 
                <asp:FileUpload ID="FUImage" runat="server" CssClass="NormalText" Visible="false"/> 
                <asp:LinkButton ID="lnkUpload" runat="server" CssClass="JustLinks" CommandName="Upload" CommandArgument='<%# Eval("MovieID") %>' Visible="false">Upload</asp:LinkButton> 
               </td> 

               </tr> 

              </table> 
             </div> 
            </ItemTemplate> 
                            </asp:DataList> 

與下面的代碼綁定它:

If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then 

       If rbMovies.SelectedValue = "0" Then 
        flag = True 
        If System.IO.File.Exists(Server.MapPath("~/MoviePoster/" & e.Item.DataItem("movieid") & "_L.jpg")) And System.IO.File.Exists(Server.MapPath("~/MoviePoster/" & e.Item.DataItem("movieid") & "_S.jpg")) Then 
         CType(e.Item.FindControl("lblMovieName"), Label).Text = e.Item.DataItem("movieid") & ". " & e.Item.DataItem("moviename") 
         CType(e.Item.FindControl("imgSmall"), System.Web.UI.WebControls.Image).ImageUrl = "~/MoviePoster/" & e.Item.DataItem("movieid") & "_S.jpg" 
        Else 
         TotalnoImage += 1 
         CType(e.Item.FindControl("lblMovieName"), Label).Text = e.Item.DataItem("movieid") & ". " & e.Item.DataItem("moviename") 
         CType(e.Item.FindControl("imgSmall"), System.Web.UI.WebControls.Image).ImageUrl = "~/MoviePoster/" & "no_image_S.jpg" 
        End If 
       End If 

       Dim divControl As HtmlGenericControl = TryCast(e.Item.FindControl("inDiv"), HtmlGenericControl) 

       If rbMovies.SelectedValue = "1" Then 
        If System.IO.File.Exists(Server.MapPath("~/MoviePoster/" & e.Item.DataItem("movieid") & "_L.jpg")) And System.IO.File.Exists(Server.MapPath("~/MoviePoster/" & e.Item.DataItem("movieid") & "_S.jpg")) Then 
         divControl.Visible = False 
        Else 
         divControl.Visible = True 
         flag = True 
         TotalnoImage += 1 
         CType(e.Item.FindControl("lblMovieName"), Label).Text = e.Item.DataItem("movieid") & ". " & e.Item.DataItem("moviename") 
         CType(e.Item.FindControl("imgSmall"), System.Web.UI.WebControls.Image).ImageUrl = "~/MoviePoster/" & "no_image_S.jpg" 
        End If 
       End If 

       If flag = True Then 
        CType(e.Item.FindControl("imgSmall"), System.Web.UI.WebControls.Image).Visible = True 
        CType(e.Item.FindControl("lblMovieName"), Label).Visible = True 
        CType(e.Item.FindControl("FUImage"), FileUpload).Visible = True 
        CType(e.Item.FindControl("lnkUpload"), LinkButton).Visible = True 
       End If 

      End If 

當rbMovies = 「0」,我想顯示在所有圖像文件夾和rbMovies =「1」時只有一個特定的圖像,即「noimage」。

當Datalist中是越來越束縛,它讓我看到如下:

enter image description here

其中信息noImage不適用它顯示空白項目,如圖3次和第10次..

我希望它在一行中。

plz幫助我。

回答

1

嘗試添加上有一個屬性顯示在表CSS類:隱藏

mytable.hidden {能見度:隱藏;}

還放在桌子上添加中用runat =「服務器」,並給它是一個名字。 你可以在代碼隱藏中添加/刪除cssclass

+0

試過這些東西,但沒有工作 –