Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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

XML
<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>
Posted
Comments
Sandeep Mewara 14-Sep-12 9:14am    
And what exactly is your problem? Where did you get stuck while trying it out? Share your code behind where you tried to do it.
Malli_S 14-Sep-12 9:17am    
The question is not so clear. Add the exact description/details using 'Improve question' option.

1 solution

common delete scenario for datalist is as follows..

VB
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900