-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathProducts.aspx.cs
More file actions
51 lines (47 loc) · 1.61 KB
/
Products.aspx.cs
File metadata and controls
51 lines (47 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Products : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindProductRepeater();
}
}
private void BindProductRepeater()
{
String CS = ConfigurationManager.ConnectionStrings["MyDatabaseConnectionString1"].ConnectionString;
Int64 CatId = Request.QueryString["cat"] == null ? 0 : Convert.ToInt64(Request.QueryString["cat"]);
Int64 SubCatId = Request.QueryString["subcat"] == null ? 0 : Convert.ToInt64(Request.QueryString["subcat"]);
using (SqlConnection con = new SqlConnection(CS))
{
using (SqlCommand cmd = new SqlCommand("procBindAllProducts", con))
{
cmd.CommandType = CommandType.StoredProcedure;
if (CatId > 0)
{
cmd.Parameters.AddWithValue("@PCategoryID", CatId);
}
if (SubCatId > 0)
{
cmd.Parameters.AddWithValue("@PSubCatID", SubCatId);
}
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dtBrands = new DataTable();
sda.Fill(dtBrands);
rptrProducts.DataSource = dtBrands;
rptrProducts.DataBind();
}
}
}
}
}