XML with Products

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 anos atrás
Hi,

I try to create an aspx page with an xml file with my Products.
I have some problem with images. I don't understand how can I do if my product have more than one picture and if I choose to add only one picture how can I view only the default one.

My purpose is to have all pictures.
If my product has only one picture with the tag [Image].
If product has two picture the first one with the tag [Image] and the second one with tag [Image1].
If product has three picture the first one with the tag [Image] and the second one with tag [Image1] and the third one with the tag [Image2]. So on. Is it possible?

Can you help me to edit my code?

I write this code. It works but I don't try to reach my purpose.

    

SqlCommand  cmdPict = null;
SqlDataReader picture = null;
string imgNr = "";
string pictName = "";
int cont=0;
string pictPath = Server.MapPath("/Content/Images/Thumbs/");

cmdPict = new SqlCommand("select top 10 p.Id, p.SeoFilename from Picture p, Product_Picture_Mapping pm where p.Id=pm.PictureId and pm.ProductId='"+myReader[0].ToString()+"' order by pm.Id asc", connection);
picture = cmdPict.ExecuteReader();
picture.Read();

while (picture.Read()) {
                
   imgNr = picture[0].ToString();
   pictName = picture[1].ToString();
       while (imgNr.Length<7) {
      imgNr = "0"+imgNr;
                  }
                        
if (File.Exists( pictPath+imgNr+"_"+pictName+".jpeg" ) ) {
writer.WriteElementString("Image",    "http://www.site.com/Content/Images/Thumbs/"+imgNr+"_"+pictName+".jpeg" );
} else if (File.Exists(pictPath+imgNr+".jpeg")) {
writer.WriteElementString("Image",  "http://www.ysite.com/Content/Images/Thumbs/"+imgNr+".jpeg" );
}  else if (File.Exists( pictPath+imgNr+"_"+pictName+"_300.jpg") ) {
writer.WriteElementString("Image","http://www.site.com/Content/Images/Thumbs/"+imgNr+"_"+pictName+"_300.jpg");
} else if (File.Exists( pictPath+imgNr+"_"+pictName+"_300.jpeg") ) {
writer.WriteElementString("Image", "http://www.site.com/Content/Images/Thumbs/"+imgNr+"_"+pictName+"_300.jpeg");
} else if (File.Exists(pictPath+imgNr+"_"+pictName+"_70.jpeg")) {
writer.WriteElementString("Image",  "http://www.site.com/Content/Images/Thumbs/"+imgNr+"_"+pictName+"_70.jpeg");
} else if (File.Exists(pictPath+imgNr+"_"+pictName+"_70.jpg")) {
writer.WriteElementString("Image",  "http://www.site.com/Content/Images/Thumbs/"+imgNr+"_"+pictName+"_70.jpg");
} else {
writer.WriteElementString("Image",  "http://www.site.com/content/images/thumbs/noDefaultImage_300.gif?for="+pictName+"&on="+category["Published"].ToString() );
}          
}




Thanks in advance.
11 anos atrás
Can you help me?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.