Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can Anyone correct this code:

in bulleted list i have
1.Below Rs.500/-
2.Between Rs.500 to Rs.1000/-

if i click any one it will load pro_id,price of it.
in my code can"t load detail...
ple crt it. or giv code for that.





coding:

protected void BulletedList3_Click(object sender, BulletedListEventArgs e)
    {
        price_range = BulletedList3.Items[e.Index].Value;
        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }
        SqlCommand cmd = new SqlCommand("select pro_img,pro_name,price from product where price = '" + price_range + "' and status='A' and type='retail' ", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataList1.DataSource = ds;
        DataList1.DataBind();
        con.Close();
    }
Posted
Comments
Reiss 21-Nov-11 3:56am    
In future please don't repost your question - if you first doesn't have enough detail, use the improve question widget to edit the question and add more details.
Sunasara Imdadhusen 21-Nov-11 5:12am    
Hi,
i have already given answer for the same :)

1 solution

Hi,
Narmatha

Please check my Answer on following link:

asp.net code for display product according to tha selected ranges?[^]

Please do let me know, if you have any doubt

CODE:
.ASPX
XML
<asp:BulletedList ID="blPriceRange"  runat="server"
           onclick="blPriceRange_Click" DisplayMode="LinkButton">
           <asp:ListItem Text="500" Value="Price = 500"></asp:ListItem>
           <asp:ListItem Text=">500" Value="Price > 500 AND Price < 1000"></asp:ListItem>
           <asp:ListItem Text=">1000" Value="Price > 1000 AND Price < 2000"></asp:ListItem>
           <asp:ListItem Text=">2000" Value="Price > 2000 "></asp:ListItem>
       </asp:BulletedList>

.ASPX.CS
C#
protected void blPriceRange_Click(object sender, BulletedListEventArgs e)
  {
      string filterCriteria = blPriceRange.Items[e.Index].Value;
      string SQLQuery = "SELECT * FROM Products WHERE " + filterCriteria;
      DataTable dt = new DataTable();
      dt = DB.ExecuteNonQuery(SQLQuery);
      if (dt.Rows.Count > 0)
      {
          GridView1.DataSource = dt;
          GridView1.DataBind();
      }
  }

Thanks,
Imdadhusen
 
Share this answer
 
v2
Comments
M.Narmatha 21-Nov-11 23:38pm    
above code not working it shows error...
Sunasara Imdadhusen 22-Nov-11 1:19am    
Can you show me an error that you have?

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