In my project I have a ListView. The ListView is bound to an XMLDataSource to grab an RSS feed. The ListView has a DataPager. In the ListView I have added a Button to each row, which grabs some values from that row and processes them.
My problem is that the Buttons after the first page no longer work. They don't appear to be firing. I really don't know why this is happening.
scheffetz
Member
12 Points
50 Posts
Buttons in ListView with DataPager don't work after 1st page
Nov 23, 2012 01:03 PM|LINK
In my project I have a ListView. The ListView is bound to an XMLDataSource to grab an RSS feed. The ListView has a DataPager. In the ListView I have added a Button to each row, which grabs some values from that row and processes them.
My problem is that the Buttons after the first page no longer work. They don't appear to be firing. I really don't know why this is happening.
My ListView:
<asp:ListView ID="ListView1" runat="server" DataSourceID="XmlDataSource1" ItemPlaceholderID="placeID"> <LayoutTemplate> <table class="rssTable"> <tr id="placeID" runat="server"></tr> </table> <asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="4"> <Fields><asp:NextPreviousPagerField /></Fields> </asp:DataPager> </LayoutTemplate> <ItemTemplate> <tr> <td> <b><asp:Label ID="lbTitle" runat="server" Text='<%# XPath("title") %>'></asp:Label></b> </td> </tr> <tr> <td> <%# XPath("description") %> </td> </tr> <tr> <td> <asp:HyperLink ID="hlStory" runat="server" NavigateUrl='<%# XPath("guid") %>' Text='<%# XPath("guid")%>'></asp:HyperLink> </td> </tr> <tr> <td> <asp:Button ID="Button1" runat="server" Text="Tweet this!" CommandArgument='<%# Container.DataItemIndex %>' /> </td> </tr> <tr> <td> <hr /> </td> </tr> </ItemTemplate> </asp:ListView>raju_mab
Member
559 Points
110 Posts
Re: Buttons in ListView with DataPager don't work after 1st page
Nov 26, 2012 09:55 AM|LINK
Please set button properties like that...
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: Buttons in ListView with DataPager don't work after 1st page
Nov 27, 2012 06:34 AM|LINK
Handle button click event or handle ListView ItemCommand event.
<tr> <td> <asp:Button ID="Button1" runat="server" Text="Tweet this!" CommandName="Com" CommandArgument='<%# Container.DataItemIndex %>' /> </td> </tr>protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName == "Com") { do any thing that you want to } }Feedback to us
Develop and promote your apps in Windows Store