I have a repeater with a image buttons in the footer for paging. I also have linkbuttons in the header for sorting.The sorting works beautifully but the footer does not fire off the itemcommand event. -
<FooterTemplate>
-
<tr>
-
<td align="left" class="footer" colspan="10">
-
-
<pagerstyle cssclass="footer" font-italic="True" />
-
<pagertemplate></pagertemplate>
-
<asp:Label ID="PageLabel" runat="server" Text='<%# GetPagingInfo() %>' Visible="true"/>
-
-
<asp:ImageButton ID="Page_First" runat="server" CommandArgument="First" CommandName="Page" ImageUrl="~/images/first_page.gif" ToolTip="Back to First Page" />
-
<asp:ImageButton ID="Page_Prev" runat="server" CommandArgument="Prev" CommandName="Page" ImageUrl="~/images/prev_page.gif" ToolTip="Back One Page" />
-
<asp:ImageButton ID="Page_Next" runat="server" CommandArgument="Next" CommandName="Page" ImageUrl="~/images/next_page.gif" ToolTip="Forward One Page" />
-
<asp:ImageButton ID="Page_Last" runat="server" CommandArgument="Last" CommandName="Page" ImageUrl="~/images/last_page.gif" ToolTip="Forward to Last Page" />
-
-
<asp:ImageButton ID="PrintAllImageButton" runat="server" CommandName="PrintAll" ImageUrl="~/images/printer.gif" ToolTip="Print all pages" Width="20px" />
-
</td>
-
</tr>
-
</FooterTemplate>
The cod ebehind in the page_Load is - ar = new Pecos.AuditReview();
-
if (!IsPostBack)
-
{
-
//ViewState["sortdir"] = "desc";
-
ViewState["page"] = "1";
-
StartAt = 1;
-
dtefrom.MaxDate = DateTime.Now;
-
dtefrom.MinDate = DateTime.Now.AddYears(-1);
-
dtethru.MaxDate = DateTime.Now;
-
dtethru.MinDate = DateTime.Now.AddYears(-1);
-
dtefrom.SelectedDate = DateTime.Now.AddDays(-1);
-
dtethru.SelectedDate = DateTime.Now;
-
TableName = String.Empty;
-
}
-
-
if(ddlTablenames.SelectedIndex<=0) LoadTableNames();
-
PageSize = Int32.Parse(Master.Pecos.Preferences["Default.PageSize"].ToString());
-
ddlRecordIds.Visible = ddlTablenames.SelectedIndex>0?true:false;
-
-
FromDate = dtefrom.SelectedDate.ToShortDateString();
-
ToDate = dtethru.SelectedDate.ToShortDateString();
-
Action = "sel";
-
rptAuditActionsInformation.DataSource = ar.GetAuditRecordsCommand();
-
rptAuditActionsInformation.DataBind();
-
this.rptAuditActionsInformation.ItemCommand += new System.Web.UI.WebControls.RepeaterCommandEventHandler(this.rptAuditActionsInformation_ItemCommand);
4 3998
You are performing a DataBind on your rptAuditActionsInformation in the Page Load event every time the page is loaded. This could be the problem.
Try moving this code to the Page PreRender event instead.
-Frinny
I moved the datasource and databind methods to the preender event but the itemcommand still doesn't fire for the footer. The thing which confuses me is the sort fires every time from the header template btu not the footer. I use very similar code in another page which does work. I can't see what's different.
I'm not sure why you are having so many problems. I created a test project based on your footer and had no problems with this.
This is the ASPX page code that I used: -
<div style="width:50%; margin:0 auto;">
-
<asp:Repeater ID="rptAuditActionsInformation" runat="server">
-
<HeaderTemplate>
-
<pagertemplate></pagertemplate>
-
<asp:LinkButton ID="Header_Page_First" runat="server" CommandArgument="First" CommandName="Page" Text="First Page" ToolTip="First Page" /> |
-
<asp:LinkButton ID="Header_Page_Prev" runat="server" CommandArgument="Prev" CommandName="Page" Text="Back" ToolTip="Back" /> |
-
<asp:LinkButton ID="Header_Page_Next" runat="server" CommandArgument="Next" CommandName="Page" Text="Forward" ToolTip="Forward" /> |
-
<asp:LinkButton ID="Header_Page_Last" runat="server" CommandArgument="Last" CommandName="Page" Text="Last Page" ToolTip="Last Page" /> |
-
<asp:LinkButton ID="Header_PrintAllLinkButton" runat="server" CommandName="PrintAll" Text="Print" ToolTip="Print" Width="20px" />
-
</HeaderTemplate>
-
<ItemTemplate>
-
<div style="margin:2px; border-bottom:solid 1px black">
-
<div>
-
<asp:Localize ID="IDPrompt" runat="server" Text="ID: "> </asp:Localize>
-
<asp:Localize ID="ID" runat="server" Text='<%# Eval("ID") %>' ></asp:Localize>
-
</div>
-
<div>
-
<asp:Localize ID="NamePrompt" runat="server" Text="Name: "> </asp:Localize>
-
<asp:Localize ID="Name" runat="server" Text='<%# Eval("Name") %>'></asp:Localize>
-
</div>
-
</div>
-
</ItemTemplate>
-
<FooterTemplate>
-
<pagerstyle cssclass="footer" font-italic="True" />
-
<pagertemplate></pagertemplate>
-
<asp:LinkButton ID="Page_First" runat="server" CommandArgument="First" CommandName="Page" Text="First Page" ToolTip="First Page" /> |
-
<asp:LinkButton ID="Page_Prev" runat="server" CommandArgument="Prev" CommandName="Page" Text="Back" ToolTip="Back" /> |
-
<asp:LinkButton ID="Page_Next" runat="server" CommandArgument="Next" CommandName="Page" Text="Forward" ToolTip="Forward" /> |
-
<asp:LinkButton ID="Page_Last" runat="server" CommandArgument="Last" CommandName="Page" Text="Last Page" ToolTip="Last Page" /> |
-
<asp:LinkButton ID="PrintAllLinkButton" runat="server" CommandName="PrintAll" Text="Print" ToolTip="Print" Width="20px" />
-
</FooterTemplate>
-
</asp:Repeater>
-
</div>
This is the VB.NET code for the page: -
Private pagedData As PagedDataSource 'Aids with paging the data displayed in the Repeater
-
Private characters As List(Of DisneyCharacter) 'Used as the data source displayed in the Repeater
-
-
'Names of Disney Characters used to create the data source for the Repeater
-
Private characterNames() As String = {"Mickey Mouse", "Mini Mouse", "Pluto", "Goofy", "Donald Duck", "Daisy Duck", "Chip", "Dale", _
-
"Abby Mallard", "Abigail Gabble", "Abis Mal", "Abu", "Adella", "The Agent", "Agent Wendy Pleakley", "Akela", "Al the Alligator", "Aladar", "Aladdin", "Alameda Slim ", "Alan-a-Dale", _
-
"Alana", "Jennifer Hale", "Alcmene", "Alice", "Amelia Gabble", "Amos Slade", "Amphitryon", "Anastasia Tremaine", "Anda", "Andrina", _
-
"Cadpig", "Calliope Lillias", "Captain Amelia", "Captain Gantu", "Captain James Hook", "Carl the Robot", "Carlotta the Maid", "Cassim"}
-
-
-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
-
'Initializing data source for the Repeater
-
InitializeRepeaterDataSource()
-
End Sub
-
-
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
-
'Setting the data source for the Repeater and binding it to the data
-
rptAuditActionsInformation.DataSource = pagedData
-
rptAuditActionsInformation.DataBind()
-
End Sub
-
-
Private Sub rptAuditActionsInformation_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptAuditActionsInformation.ItemCommand
-
-
'Handling the paging action that the user performed using the controls in the footer.
-
Select Case e.CommandArgument
-
Case "First"
-
pagedData.CurrentPageIndex = 0
-
Case "Prev"
-
If pagedData.CurrentPageIndex > 0 Then
-
pagedData.CurrentPageIndex = pagedData.CurrentPageIndex - 1
-
End If
-
Case "Next"
-
If pagedData.CurrentPageIndex < pagedData.PageCount - 1 Then
-
pagedData.CurrentPageIndex = pagedData.CurrentPageIndex + 1
-
End If
-
Case "Last"
-
pagedData.CurrentPageIndex = pagedData.PageCount - 1
-
End Select
-
-
'Storing the current page index in ViewState so that we can retrieve
-
'this information the next time the page is loaded to set the PagedDataSource control
-
ViewState("currentPage") = pagedData.CurrentPageIndex
-
End Sub
-
-
Private Sub InitializeRepeaterDataSource()
-
-
'Retrieving the list of characters from Session
-
characters = CType(Session("characters"), List(Of DisneyCharacter))
-
-
'If the list doesn't exist in Session, creating it and storing it in Session for next time
-
If characters Is Nothing Then
-
characters = New List(Of DisneyCharacter)
-
For i As Integer = 0 To characterNames.Length - 1
-
characters.Add(New DisneyCharacter(i * 111, characterNames(i)))
-
Next
-
Session("characters") = characters
-
End If
-
-
'Initializing the PagedDataSource which aids with paging the data in the Repeater
-
pagedData = New PagedDataSource
-
-
'Setting the data source for the PagedDataSource to the data
-
pagedData.DataSource = characters
-
-
'Setting the number of items to display in a page
-
pagedData.PageSize = 5
-
-
'Specifying that the control should allow paging to take place
-
pagedData.AllowPaging = True
-
-
'Setting the current page index to that which is stored in ViewState (if there is nothing in ViewState then it is 0)
-
pagedData.CurrentPageIndex = CType(ViewState("currentPage"), Integer)
-
End Sub
-
-
-
''' <summary>
-
''' This class is used as data for the repeater
-
''' </summary>
-
''' <remarks></remarks>
-
Private Class DisneyCharacter
-
Private _id As Integer
-
Private _name As String
-
Public Property ID As Integer
-
Get
-
Return _id
-
End Get
-
Set(ByVal value As Integer)
-
_id = value
-
End Set
-
End Property
-
Public Property Name As String
-
Get
-
Return _name
-
End Get
-
Set(ByVal value As String)
-
_name = value
-
End Set
-
End Property
-
Public Sub New(ByVal id As Integer, ByVal name As String)
-
Me.ID = id
-
Me.Name = name
-
End Sub
-
End Class
Everything works fine....give it a try if you want :)
-Frinny
Very simple solution, take the code outside of the repeater's footer, and use it outside of the repeater entirely. In fact, if you have an event to use, like a button click, simply never use it in the footer, problem solved.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Andrés Giraldo |
last post by:
Hi!
I'm adding an asp button to a datagrid on the ItemDataBound event, when
the user clicks on this button, I basically remove the button and create
other 2 buttons... my problem is.. the 2 last...
|
by: sonu |
last post by:
I have created a window application which has two grid
we drag and drop from one grid to other.
tn i changed that window application into DLL.
and called that dll in a web page.
grid are...
|
by: Cold Nuke |
last post by:
Hi all,
|-------------| changeSpeed |----------|simulate |-------------|
|simulation |------------->|Controller|--------->|Simulation |
|controlPanel | |Loop |second ...
|
by: Stan |
last post by:
I cannot make the link buttons fire ItemCommand from
repeater control.
Here is the code:
<asp:repeater id=rptLetters runat="server">
<itemtemplate>
<asp:linkbutton id="lnkLetter"...
|
by: James Hancock |
last post by:
I have a page, which is inherited from another page (PageEx is what I call
it) All of our pages are based on PageEx because there is a bunch of logic
stuff we do in there. My problem is, that if...
|
by: sri_san |
last post by:
Hello Group,
I use a datagrid with a linkbutton to delete the selected
row.
Added javascript confirm dialogue box in itembound event. The
itemCommand event does not seem to fire when I debug the...
|
by: jonathan.beckett |
last post by:
I have been working on a client project recently that is using winforms
..NET user controls within web pages in Internet Explorer, and need to
find out how to make the user control communicate back...
|
by: BartMan |
last post by:
Greetings,
I am trying to fire aysnc events in c++/clr, and I can't seem to get it to
work.
It seems to work fine in c#, but when I try c++/clr, I can't seem to get it
to compile in the c++/clr...
|
by: rajkumarbathula |
last post by:
Hi
I am struckup with a big issue. ie., On my Page i am rendering 2 dynamic datalists each has dynamic link buttons.
my problem is: i am not able to handle ItemCommandEvent of both the...
|
by: siva prasanth |
last post by:
Hi all
I am using C# to create add-ins
But events are not firing in citrix environment
can u suggest solution
Thanks in advance
siva
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |