la pagination ca vous dis quelque chose.
Salut tous le monde voici d'abord mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
<form id=AdminDestForm method=post runat="server">
<fieldset id=fsListObjet runat="server"><legend>Liste des objets</legend>
<asp:datagrid id=dgObjet runat="server" width="100%" horizontalalign="Center" allowsorting="false" allowpaging="True" allowcustompaging="True" onpageindexchanged=dgObjet autogeneratecolumns="False" cellpadding="3" gridlines="Horizontal" itemstyle-height="30">
<alternatingitemstyle wrap="False" cssclass="Tableau_content_alternate"></alternatingitemstyle>
<itemstyle wrap="False" height="30px" cssclass="Tableau_content"></itemstyle>
<headerstyle cssclass="Tableau_top"></headerstyle>
<columns>
<asp:boundcolumn datafield="macro" sortexpression="macro" headertext="macro"><headerstyle width="15%"></headerstyle>
</asp:boundcolumn>
<asp:boundcolumn datafield="no" sortexpression="no" headertext="Numéro de l'état"><headerstyle width="15%"></headerstyle>
</asp:boundcolumn>
<asp:boundcolumn datafield="dest" sortexpression="dest" headertext="Nom du destinataire"><headerstyle width="20%"></headerstyle>
</asp:boundcolumn>
<asp:boundcolumn datafield="D" sortexpression="D" headertext="Mode d'envoi"><headerstyle width="15%"></headerstyle>
</asp:boundcolumn>
<asp:boundcolumn datafield="C" sortexpression="C" headertext="Type de compression"><headerstyle width="15%"></headerstyle>
</asp:boundcolumn>
<asp:boundcolumn datafield="P" sortexpression="P" headertext="Protection"><headerstyle width="15%"></headerstyle>
</asp:boundcolumn>
<asp:templatecolumn><headerstyle width="5%"></headerstyle>
</asp:templatecolumn>
</columns>
<pagerstyle cssclass="Tableau_top" mode="NumericPages"></pagerstyle>
</asp:datagrid>
</fieldset>
</form> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
private void Page_Load(object sender, System.EventArgs e)
{
// Déclaration de mon DataTable.
// Déclaration de mon DataRows.
// Déclaration de mon DataView.
DataTable Dt = new DataTable();
// Ajout des entêtes de colonnes a mon DataTable.
Dt.Columns.Add(new DataColumn("Macro",typeof (string)));
Dt.Columns.Add(new DataColumn("No",typeof (string)));
Dt.Columns.Add(new DataColumn("Dest",typeof (string)));
Dt.Columns.Add(new DataColumn("D",typeof (string)));
Dt.Columns.Add(new DataColumn("C",typeof (string)));
Dt.Columns.Add(new DataColumn("P",typeof (string)));
ArrayList listeLigne = new ArrayList() ;
//Lecture de mon fichier
string ligne = " " ;
StreamReader sr=File.OpenText(@"C:\Documents and Settings\i.abarkan\Desktop\REF\SI4DEST.dat") ;
while ((ligne = sr.ReadLine()) != null)
{
if (ligne != null && ligne != string.Empty)
{
string [] listeChaine = ligne.Split('\t') ;
listeLigne.Add(listeChaine) ;
string machaine = listeLigne.ToString();
}
}
for (int i = 0 ; i < listeLigne.Count; i++ )
{
DataRow Dr = Dt.NewRow();
string [] tmp = (string[]) listeLigne[i];
for(int j = 0; j < tmp.GetLength(0); j++)
{
Dr[j] = tmp[j];
}
Dt.Rows.Add(Dr);
}
// Association de mon DataView a mon Datagrid.
DataView Dv = new DataView(Dt);
dgObjet.DataSource = Dv;
dgObjet.DataBind();
if (!IsPostBack)
{
startIndex=0;
dgObjet.VirtualItemCount=200;
}
BindGrid();
}
}
void dgObjet_Page(Object sender, DataGridPageChangedEventArgs e)
{
startIndex = e.NewPageIndex * dgObjet.PageSize;
dgObjet.CurrentPageIndex = e.NewPageIndex;
BindGrid();
}
void BindGrid()
{
dgObjet.DataSource = CreateDataSource();
dgObjet.DataBind();
ShowStats();
}
void ShowStats()
{
lblEnabled.Text = "AllowPaging est " + dgObjet.AllowPaging;
lblCustom.Text = "AllowCustomPaging est " + dgObjet.AllowCustomPaging;
lblCurrentIndex.Text = "CurrentPageIndex est " + dgObjet.CurrentPageIndex;
lblPageCount.Text = "PageCount est " + dgObjet.PageCount;
lblVirtual.Text = "VirtualItemCount est " + dgObjet.VirtualItemCount;
lblPageSize.Text = "PageSize est " + dgObjet.PageSize;
}
} |
Je ne sais pas pourquoi dans ma page aspx la pagination de mon DataGrid ne marche pas.