フォルダから画像を取得してデータリストに画像を表示します。 データリストの[削除]ボタンをクリックすると、フォルダ内の画像を削除します。データリストの削除ボタンを使用してフォルダから画像を削除
はここに私の削除ボタンのコードです:私は削除したい正確なイメージ名を取得する方法がわからない
protected void delete_onClick(object sender, EventArgs e)
{
string fileName = sender as string;
File.Delete(Server.MapPath(fileName));
FileInfo fInfo;
fInfo = new FileInfo(fileName);
fInfo.Delete();
gvImages.DataBind();
}
、各画像と削除ボタンがあります。あなたがボタンの上にコマンド名を使用する必要があります
<div>
<asp:DataList ID="gvImages" RepeatColumns="5" RepeatDirection="Horizontal" GridLines="Horizontal"
runat="server" BorderColor="#336699" BorderStyle="Solid" ShowHeader="true">
<ItemTemplate>
<center>
<table>
<tr>
<td style="width: 90px; height: 90px">
<img id="PICID" runat="server" src='<%# Container.DataItem %>' alt='' style="height: 100px;
width: 100px;" />
<br />
<asp:Button ID="Delete" Height="22px" OnClick="delete_onClick" Width="100px" runat="server"
Text="Delete Picture" /><br />
</td>
</tr>
</table>
</center>
</ItemTemplate>
</asp:DataList>
</div>
本当にありがとうございます。私のproblem.againを解決してください –