/// <summary> /// Bind Attributes List. /// </summary> protected void BindSkuAttributes() { // Set ProductId productId = Convert.ToInt16(lstProduct.SelectedValue); if (productId != 0) { ProductAdmin _adminAccess = new ProductAdmin(); DataSet ds = _adminAccess.GetProductDetails(productId); //Check for Number of Rows if (ds.Tables[0].Rows.Count != 0) { //Check For Product Type productTypeID = int.Parse(ds.Tables[0].Rows[0]["ProductTypeId"].ToString()); } DataSet MyDataSet = _adminAccess.GetAttributeTypeByProductTypeID(productTypeID); if (MyDataSet.Tables[0].Rows.Count > 0) { //Repeats until Number of AttributeType for this Product foreach (DataRow dr in MyDataSet.Tables[0].Rows) { //Bind Attributes DataSet _AttributeDataSet = _adminAccess.GetAttributesByAttributeTypeIdandProductID(int.Parse(dr["attributetypeid"].ToString()), productId); System.Web.UI.WebControls.DropDownList lstControl = new DropDownList(); lstControl.ID = "lstAttribute" + dr["AttributeTypeId"].ToString(); ListItem li = new ListItem(dr["Name"].ToString(), "0"); li.Selected = true; lstControl.DataSource = _AttributeDataSet; lstControl.DataTextField = "Name"; lstControl.DataValueField = "AttributeId"; lstControl.DataBind(); lstControl.Items.Insert(0, li); //Add Dynamic Attribute DropDownlist in the Placeholder ControlPlaceHolder.Controls.Add(lstControl); Literal lit1 = new Literal(); lit1.Text = " "; ControlPlaceHolder.Controls.Add(lit1); } pnlAttribteslist.Visible = true; } else { pnlAttribteslist.Visible = false; } } else { pnlAttribteslist.Visible = false; } }
/// <summary> /// Bind Attributes List. /// </summary> protected void BindSkuAttributes() { ProductAdmin adminAccess = new ProductAdmin(); DataSet MyDataSet = adminAccess.GetAttributeTypeByProductTypeID(productTypeID); //Repeats until Number of AttributeType for this Product foreach (DataRow dr in MyDataSet.Tables[0].Rows) { //Bind Attributes DataSet AttributeDataSet = adminAccess.GetAttributesByAttributeTypeIdandProductID(int.Parse(dr["attributetypeid"].ToString()),ItemId); System.Web.UI.WebControls.DropDownList lstControl = new DropDownList(); lstControl.ID = "lstAttribute" + dr["AttributeTypeId"].ToString(); ListItem li = new ListItem(dr["Name"].ToString(), "0"); li.Selected = true; lstControl.DataSource = AttributeDataSet; lstControl.DataTextField = "Name"; lstControl.DataValueField = "AttributeId"; lstControl.DataBind(); lstControl.Items.Insert(0, li); //Add Dynamic Attribute DropDownlist in the Placeholder ControlPlaceHolder.Controls.Add(lstControl); Literal lit1 = new Literal(); lit1.Text = " "; ControlPlaceHolder.Controls.Add(lit1); } }