Click here to Skip to main content
15,885,998 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi can anyone help me.. Why this itemcommand doesn't works properly, when i click the remove button??


C#
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;
       }




XML
<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") %>' />
                      <br />

                      <asp:LinkButton ID="linkremove" runat="server" CommandName="Remove" Text="Remove"></asp:LinkButton>
                      </div>

                  </ItemTemplate>


                  </asp:DataList>



I cant remove particular image when i click the remove button..
Posted
Updated 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..
[no name] 10-Jan-13 5:37am    
i am not getting what r u wanna to try!!
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

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
 
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