如何计算datalist项目(这是一个图像)

时间:2012-06-14 08:10:11

标签: javascript asp.net datalist

我想在javascript中计算Datalist中的项目图像(ImageUploaded)我该怎么做。

 <asp:DataList ID="DataListUploadedPhotos" ClientIDMode="Static" runat="server" RepeatDirection="Horizontal" RepeatColumns="3" CellPadding="10" CellSpacing="10" OnItemDataBound="DataListUploadedPhotos_ItemDataBound" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<table border="0" cellpadding="2" cellspacing="0" align="left" width="100%">
<tr> <td align="left" style="width:200px; height:30px">
    <b>
<asp:Label ID="LabelImageTitle" runat="server" Text='<%#Eval("title")%>' Height="10px"></asp:Label>
 </b> </td> <td align="right">  </td>  </tr> <tr>  <td align="center" colspan="2" style="background-color: #eeeeee; width: 260px; height: 260px" valign="middle">
 <asp:Image ID="ImageUploaded" runat="server" ImageUrl='<%#"../upload/photos/LargeThumbs/"+Eval("fileName")%>'
AlternateText='<%#Eval("title")%>' ClientIDMode="Static"  Style="border: 5px solid #eeeeee;" onclick='<%# "return ImageSelected(this.id, " + Eval("photoId") +",\"ContentPlaceHolder1_txtIds\");"%>' /></td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
  <a href='<%#"../upload/photos/PopUpThumbs/"+Eval("fileName")%>'>
 <asp:ImageButton ID="ImageButtonResultClose" runat="server" ImageUrl="~/images/enlarge.png" /> </a> 
 <asp:Label ID="LabelPhotoid" runat="server"  Text='<%#Eval("photoId")%>'></asp:Label>
                                                                        </td>
                                                                        <td>
 <asp:ImageButton ID="details" runat="server" ImageUrl="~/images/details.png" OnClick="details_Click"
                                                                            CommandArgument='<%#Eval("photoId")%>'/>
</td></tr>
                                                                <tr>
                                                                    <td>
                                                                        &nbsp;
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </ItemTemplate>
                                                    </asp:DataList>

2 个答案:

答案 0 :(得分:0)

您需要计算要上传图像的文件夹中的项目 像这样的东西

string mydir = @"C:\images\";
string[] files;
int numberofFiles;

files = Directory.GetFiles(mydir);
numberofFiles = files.Length;

string nextFileName = (numberofFiles + 1).ToString() + ".jpg";

如果有帮助,请告诉我

答案 1 :(得分:0)

为您的图片添加一个类,例如ClassName = "imgUploaded"。如果您使用jQuery,则img的计数将为$(".imgUploaded").length

相关问题