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')" ;
}
}
}