Bonjour

jai un controle table auquel j'ajoute des lignes dynamiquement vai une fonction appelé dans le page_load , problème : après un postback, je perds toutes les lignes ajoutées.
je cré ces lignes uniquement au premier chargement, tout se passe comme si le viewstate de mon tableau ne fonctionnait pas
meri de votre aide

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
 protected void Page_Load(object sender, EventArgs e)
    {
 
        if (! Page.IsPostBack)
        {
            int an = 2006; // année 2006
            int mois = 12; // mois de novembre
            DateTime debut = new DateTime(an, mois, 1);
            DateTime fin = new DateTime(an, mois, 31);
            Generer(debut, fin);
 
        }
 
    }
 
    public  void Generer(DateTime debut,DateTime fin)
    {
 
        TimeSpan diff = fin - debut;
        int nbjours = diff.Days + 1;
        DateTime tmpd = debut;
 
               tCorps.Attributes.Add("Border", "1");
        tCorps.Attributes.Add("style", "WIDTH:100%;HEIGHT:100%;cellspacing:0;cellpadding:0;");
 
        TableRow trHead = new TableRow();
 
        TableCell tdCell1 = new TableCell();
        TableCell tdCell2 = new TableCell();
        tdCell1.RowSpan = 3;
        tdCell1.Text  = "Colza";
        trHead.Controls.Add(tdCell1);
 
        tdCell2.ColumnSpan = nbjours;
       tdCell2.Text = debut.ToString("MMMM yyyy");
        trHead.Controls.Add(tdCell2);
         tCorps.Controls.Add(trHead);
        TableRow trjour = new TableRow();
 
        while (tmpd <= fin )
        {
            TableCell tdjour = new TableCell();
            tdjour.Attributes.Add("style", "cellspacing:0;cellpadding:0;");
            tdjour.Attributes.Add("class", "fondMois");
            tdjour.Text = tmpd.ToString("ddd");
            trjour.Cells.Add(tdjour);
 
            tmpd=tmpd.AddDays(1);
        }
        tCorps.Rows.Add(trjour);
        tmpd = debut;
        TableRow trjour1 = new TableRow();
 
        while (tmpd <= fin )
        {
            TableCell tdjour1 = new TableCell();
            tdjour1.Attributes.Add("style", "cellspacing:0;cellpadding:0;");
            tdjour1.Attributes.Add("class", "fondMois");
            tdjour1.Text  = tmpd.ToString("%d");
            trjour1.Cells.Add(tdjour1);
            tmpd=tmpd.AddDays(1);
 
        }
        tCorps.Rows.Add(trjour1);
 
 
 
    }