Click here to Skip to main content
12,354,955 members (61,346 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
Hi can anyone help me.. Why this itemcommand doesn't works properly, when i click the remove button??


protected void list_ItemCommand1(object source, DataListCommandEventArgs e)
   {
       try
       {
           if (e.CommandName == "Remove")
           {
               HiddenField id1 = (HiddenField)list.Items[e.Item.ItemIndex].FindControl("hf1");
               if (dbo.deleterecords("image", "id='" + id1.Value + "'") == true)
               {
 
                  
                   lbldel.Text = "Image Deleted";
               }
           }
       }
       catch (Exception ex)
       {
           Exception E = ex;
       }



<asp:DataList ID="list" runat="server" RepeatColumns="5" ShowFooter="true" ShowHeader="true" Width="98%" OnItemCommand="list_ItemCommand1">
                  <ItemTemplate>
                  <div align="center">
                  <asp:Image ID="img" runat="server" BorderColor="white" BorderWidth="2" Height="100"
                      ImageUrl='<%# "~/Image.aspx?id="+Eval("id") %>' Width="100px"/>
                      <asp:HiddenField ID="hf1" runat="server" Value='<%# Eval("id") %>' />


I cant remove particular image when i click the remove button..
Posted 9-Jan-13 23:12pm
Edited 9-Jan-13 23:27pm
v2
Comments
Sanjeev Alamuri 10-Jan-13 5:17am
   
Whats the error you are facing?
Sasikala Gurusamy 10-Jan-13 5:27am
   
I cant remove particular image when i click the remove button..
Sasikala Gurusamy 10-Jan-13 5:40am
   
Here am displaying uploaded images in datalist..this admin part. here i want to delete particular image means , am going to click remove button.. but this is not working..

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,

Please debug first in Page_Load event and by pressing F10 go ahead and check if there is any error which can be the cause of your problem.

Thanks
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100