protected void Product_Category_Id_Command(object sender, CommandEventArgs e) { LinkButton lLinkButton = Product_Category_Repeater.Controls[0].Controls[0].FindControl("Product_Category_Id") as LinkButton; if (e.CommandArgument.ToString() == "All") { lLinkButton.CssClass = "btn-primary"; } else { lLinkButton.CssClass = ""; } foreach (RepeaterItem lRepeaterItem in Product_Category_Repeater.Items) { lLinkButton = lRepeaterItem.FindControl("Product_Category_Id") as LinkButton; if (lLinkButton.CommandArgument == e.CommandArgument.ToString()) { lLinkButton.CssClass = "btn-primary"; } else { lLinkButton.CssClass = ""; } } if (e.CommandArgument.ToString() == "All") { Refresh_Products(); } else { MySqlConnection dbconn = new MySqlConnection(CommonClass.connectionstring); dbconn.Open(); MySqlCommand lMySqlCommand = new MySqlCommand(); lMySqlCommand.CommandText = "GET_ACIVE_PRODUCTS_BY_CATEGORY"; lMySqlCommand.CommandType = System.Data.CommandType.StoredProcedure; lMySqlCommand.Connection = dbconn; lMySqlCommand.Parameters.AddWithValue("P_PRODUCT_CATEGORY_ID", e.CommandArgument.ToString()); (Product_ListView.FindControl("DataPager1") as DataPager).SetPageProperties(0, 12, false); (Product_ListView.FindControl("DataPager2") as DataPager).SetPageProperties(0, 12, false); using (MySqlDataAdapter lMySqlDataAdapter = new MySqlDataAdapter(lMySqlCommand)) { DataTable dt = new DataTable(); lMySqlDataAdapter.Fill(dt); Product_ListView.DataSource = dt; Product_ListView.DataBind(); } dbconn.Close(); } }
protected void Refresh_Products(MySqlConnection dbconn) { MySqlCommand lMySqlCommand = new MySqlCommand(); lMySqlCommand.CommandText = "GET_ACIVE_PRODUCTS"; lMySqlCommand.CommandType = System.Data.CommandType.StoredProcedure; lMySqlCommand.Connection = dbconn; lMySqlCommand.Parameters.AddWithValue("PHOTO_IND", "0"); using (MySqlDataAdapter lMySqlDataAdapter = new MySqlDataAdapter(lMySqlCommand)) { DataTable dt = new DataTable(); lMySqlDataAdapter.Fill(dt); Product_ListView.DataSource = dt; Product_ListView.DataBind(); } }