Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
helo to all i am making an asp.net web application...I have given the system of rating the product..

for that i have taken four radio buttons behnid that product, Ist radio of 25%, second of 50% and

so on...
user rate that product and i saved it in database
1.)product id
2.)userid
3.)rating.

Now suppose when user rates the product and after that log out..now when any user login into the

software then the product which got more ratings in database should come at front page and written

as "product of the day" and the details of that product..
suppose i have two entries of t.v in database
t.v-25%
t.v-50%

and watch

watch-75%
watch-100%

now overall, watch got more rating as showing in database--

on buttonvote i have done this
C#
protected void btnvote_Click(object sender, EventArgs e)
    {
        int s=0;
        if (rd1.Checked)
        {
            s = 25;
        }
        else if (rd2.Checked)
        {
            s = 50;
        }

        else if (rd3.Checked)
        {
            s = 75;
        }

        else if (rd4.Checked)
        {
            s = 100;
        }      

        DataSet ds = new DataSet();
        OleDbDataAdapter adp = new OleDbDataAdapter("select * from ratings", con);
        adp.Fill(ds,"virtual");
        DataRow dr4;
        dr4 = ds.Tables["virtual"].NewRow();

        dr4[0] = lblname.Text;
        dr4[1] = s;
        dr4[2] = mm.Text;

        ds.Tables["virtual"].Rows.Add();

        adp.InsertCommand = new OleDbCommand();
        adp.InsertCommand.CommandText = "insert into ratings values(" + "'" + lblname.Text + "'" + 

"," + "'" + s + "'" + "," + "'" + mm.Text + "'" + ")";
        adp.InsertCommand.Connection = con;
        adp.Update(ds, "virtual");

        Response.Write("<script>alert('Thanks for your rating')</script>");
        rd1.Visible = false;
        rd2.Visible = false;
        rd3.Visible = false;
        rd4.Visible = false;
        Image1.Visible = false;
        Image2.Visible = false;
        HyperLink1.Visible = false;
        btnvote.Visible = false;
        Label4.Visible = false;
        Label3.Visible = false;        
    }



after that what will i have to do plz help me.
Posted
Updated 8-Jul-10 20:10pm
v2
Comments
Sandeep Mewara 9-Jul-10 2:10am    
Use PRE tags for formatting code part. It helps in reading the question better.

You need to start again. Your code is not usable for a number of reasons

1 - lack of concern for security
2 - no design
3 - unreadable due to poor variable names
4 - use of response.write, which is useless in ASP.NET due to inability to position output
5 - general lack of design or code quality

Once you have a decent code base, a SQL request with an ORDER BY clause will order your items by rating.
 
Share this answer
 
Once the user pressed login button navigate to desired page and use the code below
DataTable dt;
String str="select product_name from propduct where ratio in(select max(ratio) from product);"
DataAdapter da=new DataAdapter(str,con);
da.fill(dt);

txtProductOfDay.Text=dt.rows[0][0].ToString();


Hope it can fullfil ur requiremant. :-O
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900