User controls that browse categories in a generic Web site are typically located on the left side of most asp.net pages, enabling users to quickly find products by category. Recently met a customer, because the product on his website is not many, so the request in the original category browsing based on the product added. A more convenient, and secondly lengthened the length of the left navigation bar to make the page more coordinated. The original category navigation bar is implemented by repeater, now need to add to each category of commodity information, so I thought of the original repeater nested repeater. The implementation interface is as follows:
Background Code section (partial code):
When binding category name, the product under the binding category
private void Rptcategories_itemdatabound (object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
Bll. Products Products =new BLL. Products ();
if (E.item.itemtype = = ListItemType.Item | | E.item.itemtype = = ListItemType.AlternatingItem)
{
Repeater rptproduct = (Repeater) e.item.findcontrol ("rptproduct");
Find the data item that the taxonomy repeater associated with
DataRowView ROWV = (DataRowView) e.Item.DataItem;
Extract Category ID
int Categorieid = Convert.ToInt32 (rowv["ID"]);
According to the classification ID query the products under this category, and binding products repeater
Rptproduct.datasource = products. Getproductsbycategorieid (Categorieid);
Rptproduct.databind ();
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.