示例#1
0
        private void BindSpecificationData(int cateid)
        {
            DataTable dt         = pBll.GetList("cateid = " + cateid + " and paratype=" + (int)CategoryParameterType.规格参数).Tables[0];
            DataTable ValueTable = pvBll.GetList(" productid = " + ProductID).Tables[0];

            Hashtable vtable = new Hashtable();

            foreach (DataRow row in ValueTable.Rows)
            {
                vtable.Add(Convert.ToInt32(row["paraid"]), row["paravalue"]);
            }

            GridView_Specification.DataSource = dt;
            GridView_Specification.DataBind();

            for (int i = 0; i < GridView_Specification.Rows.Count; i++)
            {
                RadioButtonList ValueList     = ((RadioButtonList)GridView_Specification.Rows[i].Cells[1].FindControl("RadioList_SpecificationValue"));
                string          SelectedValue = String.Empty;

                if (vtable[Convert.ToInt32(dt.Rows[i]["paraid"])] != null)
                {
                    SelectedValue = vtable[Convert.ToInt32(dt.Rows[i]["paraid"])].ToString();
                }
                string[] Values = dt.Rows[i]["paravalues"].ToString().Split(',');

                for (int j = 0; j < Values.Length; j++)
                {
                    ListItem item = new ListItem();

                    item.Text  = Values[j];
                    item.Value = j.ToString();

                    if (item.Text == SelectedValue)
                    {
                        item.Selected = true;
                    }

                    ValueList.Items.Add(item);
                }
            }
        }
        private void BindSpecificationData()
        {
            DataTable dt = pBll.GetList("cateid = " + CategoryID + " and paratype=" + (int)CategoryParameterType.规格参数).Tables[0];

            GridView_Specification.DataSource = dt;
            GridView_Specification.DataBind();

            for (int i = 0; i < GridView_Specification.Rows.Count; i++)
            {
                RadioButtonList ValueList = ((RadioButtonList)GridView_Specification.Rows[i].Cells[1].FindControl("RadioList_SpecificationValue"));

                string[] Values = dt.Rows[i]["paravalues"].ToString().Split(',');
                for (int j = 0; j < Values.Length; j++)
                {
                    ListItem item = new ListItem();

                    item.Text  = Values[j];
                    item.Value = j.ToString();

                    ValueList.Items.Add(item);
                }
            }
        }