i just want to calculate the ratings based in the product and display five recommended product based on the rating i done all the things by using below code ...but i have one problem while i executing the code lost product details only displayed in that top five model so i need to separate the string and assign that into different string or array based on that i need to retrieve the data about that top five product details fro database
---------------------------
Code for rating calculation:
----------------------------
try
{
con1.Open();
SqlCommand cmd1 = new SqlCommand("select top 5 model, sum(rating)/count(name) as ratetotal,count(name) as nocustomer from ratings where ptype='laptop' GROUP BY model order by ratetotal desc", con1);
SqlDataReader rdr = cmd1.ExecuteReader();
while (rdr.Read())
{
lap.Add(rdr[0].ToString());
}
}
---------------------------------------
code for retrieve the data from database:
ArrayList dat = ratingdata.rating.laprating();
string model;
foreach (object x in dat)
{
model = x.ToString();
string[] modelna = model.Split(',');
string first = modelna[0].ToString();
try
{
con.Open();
SqlCommand cmds = new SqlCommand("select Pictureurl,pbrandname,model,price from productdetails where model=@model", con);
cmds.Parameters.AddWithValue("@model",model.ToString());
SqlDataAdapter das = new SqlDataAdapter(cmds);
DataSet dsa = new DataSet();
das.Fill(dsa, "productdetails");
DataList2.DataSource = dsa.Tables[0];
DataList2.DataBind();
}
============================================================