Bonjour , j'ai un probleme avec des éléments dans une table, il s'agit d'un htmlinputimage
qui me permet lorsque l'on clique dessus d'aller cher toute sles caractétistiques du produit.
Quand je démarre la page se charge normalement avec X record dans la table.
Je change de catégorie et j'ai Y record qui s'affichent, mais lorsque je clique sur le premier record de la catégorie, il me donne les caractéristique de la x+1 image. Au lieu de la première.
Le processus se passe ainsi
Page Load
clique button catégorie = traitement évènement "Click" + pageload pour afficher les record de la catégorie sélectionnée
Je clique alors sur l'image qui m'intérresse
de nouveau
Page Load
traitement "ServerClick" qui estcensé me renvoyer dans la page affichant les détails.
Le probleme est que si j'ai 3 record, je change de catégorie, j'en ai alors 10, je sélectionne le premier et il me renvoie les infos du 4èmé.
J'en conclu que le serveur a perdu les pédales, que lors du changement de catégorie, il a effectivement changer l'affichage mais n'a pas noté que la table a été vidée, le résultat est qu'il additionne des records, comme si il avais toujours les records de la première catégorie, son index est inchangé bien qu'a l'affichage tout soit correcte.
voici le code de mon page load qui fait le remplissage de la table, que faire de plus ?
try
{
//oleDbConnection1.Open();
aConnection.Open();
//create the datareader object to connect to table
OleDbCommand aCommand =
new OleDbCommand(cmdsql, aConnection);
OleDbDataReader aReader = aCommand.ExecuteReader();
//Iterate throuth the database
int cptrecord =0;
string [] IDItem= new string [10];
string [] TitreFr=new string [10];
string [] DescrFR=new string [10];
string [] Promo=new string [10];
string [] PrixVente=new string [10];
string [] PrixAchat=new string [10];
string [] LocImage=new string [10];
string [] Langues = new string[10];
string [] Precom = new string[10];
string [] DateDispo = new string[10];
DescrFR.Initialize();
if (ip!=0)
{
for (int ff=0; ff<ip;ff++)
{
for (int jj=0;jj<10;jj++)
{
aReader.Read();
}
}
}
while(aReader.Read()&&(cptrecord<10))
{
IDItem[cptrecord] = aReader.GetInt32(0).ToString();
TitreFr[cptrecord] = aReader.GetString(1);
DescrFR[cptrecord] = aReader.GetString(2);
//if (nom=="") nom=" ";
Promo[cptrecord] = (aReader.GetBoolean(3).ToString());
//if (prenom=="") prenom=" ";
PrixVente[cptrecord] = (aReader.GetFloat(4).ToString());
//if (adresse=="") adresse=" ";
PrixAchat[cptrecord] = (aReader.GetFloat(5).ToString());
//if (ville=="") ville=" ";
LocImage[cptrecord] = (aReader.GetString(6));
TableRow r =
new TableRow();
TableCell c =
new TableCell();
cptrecord++;
}
if (cptrecord>0)
{
double MontantTotal = 0;
TableItems.Rows.Clear();
TableRow h =
new TableRow();
//string tempcount = Session.Contents[5].ToString();
//string [] tempcontent = (string []) Session.Contents[6];
TableHeaderCell myheader1 =
new TableHeaderCell();
TableHeaderCell myheader2 =
new TableHeaderCell();
TableHeaderCell myheader3 =
new TableHeaderCell();
TableHeaderCell myheader4 =
new TableHeaderCell();
myheader1.BorderColor = System.Drawing.Color.Black;
myheader1.BorderWidth = 2;
myheader1.ForeColor = myheader2.ForeColor= myheader3.ForeColor = myheader4.ForeColor = System.Drawing.Color.DarkBlue;
myheader1.Font.Bold =
true;
myheader1.Text = "Titre";
myheader1.Width = Unit.Point(100);
/*myheader2.BorderColor = System.Drawing.Color.Black;
myheader2.BorderWidth = 2;
myheader2.Text = "Description";
myheader2.Font.Bold = true;
myheader2.Width = Unit.Point(150);*/
myheader3.BorderColor = System.Drawing.Color.Black;
myheader3.BorderWidth = 2;
myheader3.Font.Bold =
true;
myheader3.Width = Unit.Point(75);
myheader3.Text = "Pochette";
myheader4.BorderColor = System.Drawing.Color.Black;
myheader4.BorderWidth = 2;
myheader4.Font.Bold =
true;
myheader4.Width = Unit.Point(40);
myheader4.Text = "Prix TVAC";
myheader1.HorizontalAlign = HorizontalAlign.Left;
myheader2.HorizontalAlign = HorizontalAlign.Left;
myheader3.HorizontalAlign = HorizontalAlign.Left;
myheader4.HorizontalAlign = HorizontalAlign.Left;
h.Cells.Add(myheader1);
//h.Cells.Add(myheader2);
h.Cells.Add(myheader3);
h.Cells.Add(myheader4);
TableItems.Rows.Add(h);
TableRow r;
TableCell c ;
TableCell d ;
TableCell efield ;
TableCell p ;
TableCell idfield;
for (int i = 0;i<cptrecord;i++)
{
r =
new TableRow();
c =
new TableCell();
d =
new TableCell();
efield =
new TableCell();
p =
new TableCell();
idfield =
new TableCell();
TableItems.Font.Size = FontUnit.XSmall;
efield.ForeColor = d.ForeColor = c.ForeColor = System.Drawing.Color.DarkBlue;
p.ForeColor = System.Drawing.Color.Red;
c.BorderColor = System.Drawing.Color.Black;
c.BorderWidth = 1;
c.Wrap =
true;
c.Width = Unit.Point(250);
c.Controls.Add(
new LiteralControl(TitreFr[i]));
/*d.BorderColor = System.Drawing.Color.Black;
d.BorderWidth = 1;
d.Width = Unit.Point(150);
d.Controls.Add(new LiteralControl(DescrFR[i]));*/
efield.BorderColor = System.Drawing.Color.Black;
efield.BorderWidth = 1;
efield.Width = Unit.Point(80);
efield.VerticalAlign = VerticalAlign.Middle;
efield.HorizontalAlign = HorizontalAlign.Right;
/*double PrixUnitaire = GetPriceForItem(tempcontent[i].Substring(2));
double subtotal = PrixUnitaire * (int.Parse(tempcontent[i].Substring(0,1)));
MontantTotal += (PrixUnitaire * (int.Parse(tempcontent[i].Substring(0,1))));*/
//efield.Text = string.Format("{0:###0.00}",decimal.Parse(subtotal.ToString()));
HtmlInputImage myimage =
new HtmlInputImage();
myimage.Src = LocImage[i];
myimage.Style.Add("height","40");
myimage.Style.Add("width","30");
myimage.Style.Add("runat","server");
myimage.Value = IDItem[i];
myimage.CausesValidation=
true;
myimage.ServerClick +=
new ImageClickEventHandler(myimage_ServerClick);
/* ImageButton tmpbutton = new ImageButton();
tmpbutton.ImageUrl=LocImage[i];
tmpbutton.Height = Unit.Point(80);
tmpbutton.Width =Unit.Point(56);
tmpbutton.Click += new ImageClickEventHandler(tmpbutton_Click);
tmpbutton.Attributes.Add("idrecord",IDItem[i]);*/
//efield.Controls.Add(tmpbutton);
efield.Controls.Clear();
efield.Controls.Add(myimage);
p.BorderColor = System.Drawing.Color.Black;
p.BorderWidth = 1;
p.Wrap =
true;
p.Width = Unit.Point(40);
p.Controls.Add(
new LiteralControl(PrixVente[i]+ " €"));
idfield.BorderColor = System.Drawing.Color.Black;
idfield.BorderWidth = 1;
idfield.Wrap =
true;
idfield.Width = Unit.Point(25);
idfield.Controls.Add(
new LiteralControl(IDItem[i]));
r.Cells.Add(c);
//r.Cells.Add(d);
r.Cells.Add(efield);
r.Cells.Add(p);
r.Cells.Add(idfield);
TableItems.Rows.Add(r);
}
}
else
{
TableItems.Rows.Clear();
Button1.Visible=Button2.Visible=
false;
}
aReader.Close();
aConnection.Close();
}
catch (Exception erro)
{
int i =0;
i++;
}