-1

我想在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>
4

2 回答 2

0

例如,给你的图像一个类ClassName = "imgUploaded"。如果你使用 jQuery,那么 img 的计数将是$(".imgUploaded").length

于 2012-06-14T08:57:40.617 回答
0

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

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

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

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

让我知道这是否有帮助

于 2012-06-14T08:47:04.237 回答