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;
}
} |
Partager