473,780 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview using pagertemplate

Hi,

I need to customize a pargertemplate with these items
a arrow to go back to the 1rst page
a arrow for the previous page
a dropdownlist with the page indexes
a arrow for the new page
a arrow for the last page.

The dropdownlist function is okay, but I m blocked with the arrows
I make something wrong when I set the arrow OnClientClick value or I miss
something that handles the event.

Any help ?

Stan

Here's my code.

The aspx part

<asp:GridView ID="CustomersGr idView"
ondatabound="Cu stomersGridView _DataBound" runat="server" AllowPaging="Tr ue"
AutoGenerateCol umns="False"
DataSourceID="O bjectDataSource 1" AllowSorting="t rue" Width="700"
CellPadding="0" BorderWidth="0" CellSpacing="0" >
<HeaderStyle CssClass="heade rgrille" VerticalAlign=" Middle" />
<RowStyle CssClass="norma lrow" />
<AlternatingRow Style CssClass="alern aterow" />
<Columns>
<asp:BoundFie ld DataField="Nom" HeaderStyle-Width="400" HeaderText="Nom "
SortExpression= "s_libelle" HeaderStyle-CssClass="linkS tyleName" />
<asp:BoundFie ld DataField="Uid" HeaderStyle-Width="300"
HeaderText="Ide ntificateur" SortExpression= "s_uid" />
</Columns>
<pagertemplat e>
<div id="pagination" >
<asp:ImageButto n ID="fpremier" runat="server"
ImageUrl="../BACKOFFICE/imgappli/flechepremier.g if" Style="margin:0 5px;" />
<asp:ImageButto n ID="fprecedent " runat="server"
ImageUrl="../BACKOFFICE/imgappli/flecheprecedent .gif" Style="margin:0 5px;"
/>
<asp:dropdownli st id="PageDropDow nList" autopostback="t rue"
onselectedindex changed="PageDr opDownList_Sele ctedIndexChange d"
runat="server"/>
<asp:ImageButto n ID="fsuivant" runat="server"
ImageUrl="../BACKOFFICE/imgappli/flechesuivant.g if" Style="margin:0 5px;" />
<asp:ImageButto n ID="fdernier" runat="server"
ImageUrl="../BACKOFFICE/imgappli/flechedernier.g if" Style="margin:0 5px;" />
</div>
</pagertemplate>
</asp:GridView>
The code behind
protected void PageDropDownLis t_SelectedIndex Changed(Object sender,
EventArgs e)
{
GridViewRow pagerRow = CustomersGridVi ew.BottomPagerR ow;
DropDownList pageList =
(DropDownList)p agerRow.Cells[0].FindControl("P ageDropDownList ");
CustomersGridVi ew.PageIndex = pageList.Select edIndex;
}
protected void CustomersGridVi ew_DataBound(Ob ject sender, EventArgs e)
{

GridViewRow pagerRow = CustomersGridVi ew.BottomPagerR ow;
DropDownList pageList =
(DropDownList)p agerRow.Cells[0].FindControl("P ageDropDownList ");
ImageButton btn;
if (pageList != null)
{
for (int i = 0; i < CustomersGridVi ew.PageCount; i++)
{
int pageNumber = i + 1;
ListItem item = new ListItem(pageNu mber.ToString() );
if (i == CustomersGridVi ew.PageIndex)
item.Selected = true;
pageList.Items. Add(item);
}
}
if (pageLabel != null)
{
int currentPage = CustomersGridVi ew.PageIndex + 1;
if (currentPage == 1)
{
btn =
(ImageButton)pa gerRow.Cells[0].FindControl("f premier");
btn.ImageUrl = "../BACKOFFICE/imgappli/flechepremiera. gif";
btn =
(ImageButton)pa gerRow.Cells[0].FindControl("f precedent");
btn.ImageUrl =
"../BACKOFFICE/imgappli/flecheprecedent a.gif";
}
if (currentPage == CustomersGridVi ew.PageCount)
{
btn =
(ImageButton)pa gerRow.Cells[0].FindControl("f dernier");
btn.ImageUrl = "../BACKOFFICE/imgappli/flechederniera. gif";
btn =
(ImageButton)pa gerRow.Cells[0].FindControl("f suivant");
btn.ImageUrl = "../BACKOFFICE/imgappli/flechesuivanta. gif";
}

if (currentPage < CustomersGridVi ew.PageCount)
{
btn =
(ImageButton)pa gerRow.Cells[0].FindControl("f suivant");
btn.OnClientCli ck =
"__doPostBack(' "+CustomersGrid View.ClientID+" ','Page$Next')" ;
}
if (currentPage 1)
{
btn =
(ImageButton)pa gerRow.Cells[0].FindControl("f precedent");
btn.OnClientCli ck =
"__doPostBack(' "+CustomersGrid View.ClientID+" ','Page$Prev')" ;
}
}

}
Jun 15 '07 #1
0 2270

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8516
by: clintonG | last post by:
Briefly stated, my problem is accessing and 'setting' properties of a label control declared in the template of another control noting that the other control is an instance of the beta 2 DetailsView control which supports a PagingTemplate. Somewhere I grabbed some declarations for a PagerTemplate to display paging as: <<First < Prev Next> Last>>
3
15720
by: Dabbler | last post by:
When I try and edit the PagerTemplate it erases the default paging controls. Is there a way to add a link control to this region while still keeping the default paging controls? Thanks.
5
1989
by: Cindy Lee | last post by:
I want to have a button to view top 5 and toggle to view all on my gridview. Can this be done using paging? I don't want to show page 1, 2, 3. Just the top 5 or all. Or am I going to have to postback and change my query? If I do that I will also lose my current sorting. Any suggestions?
0
2439
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from a data view (which in turn is loaded from a manually setup DataTable for testing purposes). One of the columns in the grid is a checkbox that's tied to an event handler that'll change the .Visible property of a column with a text box. That text...
5
3007
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item list that corresponds with the number of pages, but I am unable to wire up the Selected Index Changed event. Auto PostBack is set to true and the page is posting back when the DDL is selected / chaged, but the event is never being called. Any...
1
2706
by: mark4asp | last post by:
I moved a page to another web-site and now it's broke! I had 5 pages in their own web-site. These pages have now been moved to another web-site. Everything is fine except that one of the pages, which I had trouble with in the past (i.e. same problem), is now partly broke. The paging no longer fully works in the gridview. The gvAwarded_RowDataBound code works to load the ddlPager with the correct number of pages.
1
10408
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID" OnRowCreated="ContactHistoryGrid_RowCreated" CssClass="GridViewTable" GridLines="None" CellSpacing="1" CellPadding="3" AllowSorting="True" AllowPaging="True"> <EmptyDataTemplate>
2
1340
by: Stuart Ferguson | last post by:
I am using a GridView control with auto paging in a web application I am currently developing and was looking to customise the pager. I need to make the overall page numbers larger and also change the selected page number to be larger and bolder than the other numbers how can this be done. Any help would be appreciated. Stuart
4
8367
by: marksommerville | last post by:
I have a few questions regarding accessing a gridview control from Javascript which I would really appreciate some help with. 1. The gridview contains a column of checkboxes as a template field. I have onclick Javascript on the checkbox but can't figure out how to determine the row number of the checkbox that was clicked. 2. How do I access a control within the gridview's pagertemplate? The pagertemplate contains a 1 row table with a...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.