Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working on web application where I need to raise DataList1_ItemCommand event but it is not fired.
Please look into my code

HTML Code:-

XML
<asp:DataList ID="DataList1" runat="server" Width="100%" CellPadding="0" RepeatDirection="Horizontal"
           RepeatColumns="1" OnItemDataBound="DataList1_ItemDataBound" HorizontalAlign="Center"
           OnItemCommand="DataList1_ItemCommand">
           <ItemTemplate>
               <div class="tubeblock">
                   <asp:HyperLink ID="Hyperlink1" runat="server">
                       <span><span>
                           <asp:Label ID="lblLikes" runat="server" Text='<%# Bind("Img_LikeMark") %>' SkinID="Lbl_listtxt"></asp:Label></span></span><table
                               cellspacing="0" cellpadding="0" width="100%" border="0">
                               <tbody>
                                   <tr>
                                       <td valign="top" width="97">
                                           <asp:ImageButton ID="ImageButton1" runat="server" SkinID="imgSmall" ImageUrl='<%# Bind("Image_Name","ThumbnailImages/{0}") %>'>
                                           </asp:ImageButton>
                                       </td>
                                       <td class="listtxt" valign="top">
                                           <asp:Label ID="lblimg_Title" SkinID="LBL_GalleryDisCription" runat="server" Text='<%# Bind("Image_Name") %>'></asp:Label><asp:Label
                                               ID="lblDis_bk" SkinID="LBL_GalleryDisCription" runat="server"></asp:Label><asp:Label
                                                   ID="lblDiscription" runat="server" Text='<%# Bind("Description") %>' Visible="False"></asp:Label><asp:Label
                                                       ID="lblGalleryID" runat="server" SkinID="LBL_INFO" Visible="False" Text='<%# Bind("Img_Id") %>'></asp:Label><asp:Label
                                                           ID="lblUrl" runat="server" Visible="False" Text='<%# Bind("Image_Name","ThumbnailImages/{0}") %>'></asp:Label><span></span>
                                       </td>
                                   </tr>
                               </tbody>
                           </table>
                   </asp:HyperLink>
               </div>
           </ItemTemplate>
       </asp:DataList>



C# Code
C#
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
   {
       Label lblGalleryID = (Label)(e.Item.FindControl("lblGalleryID"));
      // imgMain.ImageUrl = ((Label)(dl_Gallery.Items[0].FindControl("lblLargeUrl"))).Text.Trim().Replace("~/", "");
       Build_ImageGallery1();
   }


Here this item command not fired single time. I am not getting what's the reason.
please suggest me.

Same code is working on new one test page and this event is raised.

* Even page load event also not fired. while I click on datalist.

Thanks in advance!
Kuldeep Dwivedi
Posted
Updated 29-Jun-11 5:48am
v3
Comments
divesh12 28-Jun-11 16:53pm    
Make sense?
Kuldeep03 28-Jun-11 16:59pm    
I am not interested in any comment Mr. divesh This is not Orkut site where you leave comment. I need help.

1 solution

I think that :
in C# code you have written :
protected void DataList_ItemCommand(object source, DataListCommandEventArgs e)

but in designer you have written:
OnItemCommand="DataList1_ItemCommand"
so: "DataList1_ItemCommand"(in C# code) is different from "DataList_ItemCommand"(line 5 in your code)
 
Share this answer
 
Comments
Kuldeep03 29-Jun-11 11:53am    
Thanks for reply!

Sorry that was typing mistake here. Code is updated now. Actually name is different and I am using same name in my code.

thanks!

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