protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; Classes.Product objProduct = new Classes.Product(); SqlDataReader categoryData = objProduct.getParentCategoies(); if (categoryData == null) return; while (categoryData.Read()) { ListItem categoryItem = new ListItem(categoryData["name"].ToString(), categoryData["id"].ToString()); lstCategory.Items.Add(categoryItem); Classes.Product objProductB = new Classes.Product(); SqlDataReader childCategory = objProductB.getChildCategories(Convert.ToInt32(categoryData["id"])); if (childCategory != null) while (childCategory.Read()) { categoryItem = new ListItem("!_"+childCategory["name"].ToString(), childCategory["id"].ToString()); lstCategory.Items.Add(categoryItem); } objProductB.close(); } objProduct.close(); }