本文介绍了如何从数据列表中获取特定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何在数据列表上仅获取特定值我想删除在数据列表上显示的图像,但我只想删除特殊图像,但我有一个带有图像ID的标签,所以我想使用ID作为我的视线表
这是我的代码
how do i get only specific value on a datalist i want to delete images i display on the datalist but i only want to delete a spefic image i have a label with the image id so i want to use the id as my peremeter
here is my code
<asp:DataList ID="DataList2" runat="server" DataKeyField="pid"
DataSourceID="SqlDataSource2" RepeatColumns="3"
onselectedindexchanged="DataList2_SelectedIndexChanged">
<ItemTemplate>
<asp:Label ID="pidLabel" runat="server" Text='<%# Eval("pid") %>' />
<br />
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# Eval("picurl","~/images/{0}") %>' BorderColor="Red"
BorderStyle="Groove" Height="200px" Width="200px" /><br />
uploadedby:
<asp:Label ID="uploadedbyLabel" runat="server"
Text='<%# Eval("uploadedby") %>' />
<br />
<br />
<asp:Button ID="Button3" runat="server" Text="Delete" OnClick = "btnPhotos_Click"/>
</ItemTemplate>
</asp:DataList>
推荐答案
Sub Delete_Command(ByVal sender As Object, _
ByVal e As DataListCommandEventArgs)
'---retrieves the key for the row that you want to delete---
Response.Write(DataList1.DataKeys(e.Item.ItemIndex))
'---codes to delete row here----
End Sub
这篇关于如何从数据列表中获取特定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!