private void Bind()
{
int pid = int.Parse(this.Request.QueryString["pid"].ToString());
DataRow row = pro.getoneproduct(pid);
this.productnameliteral.Text = row["productname"].ToString();
this.ltProductorders.Text = row["productorders"].ToString();
this.IMG1.Src = "pic/" + row["imagepath"].ToString();
this.IMG1.Alt = "pic/" + row["imagepath"].ToString();
this.type_1nameliteral.Text = t_1.gettypename(int.Parse(row["typeid_1"].ToString()));
this.type_2nameliteral.Text = t_2.gettypename(int.Parse(row["typeid_2"].ToString()));
this.pointcountliteral.Text = row["pointcount"].ToString();
this.countliteral.Text = (int.Parse(row["count"].ToString()) > int.Parse(row["sellcount"].ToString())) ? row["count"].ToString() : "缺货";
this.sellcountliteral.Text = row["sellcount"].ToString();
this.priceliteral.Text = row["price"].ToString();
this.userpriceliteral.Text = row["userprice"].ToString();
this.specialsliteral.Text = row["specialsprice"].ToString();
this.descriptionliteral.Text = row["description"].ToString();
this.drpColor.DataSource = row["pcolor"].ToString().Split(',');
this.drpColor.DataBind(); this.drpSize.DataSource = row["psize"].ToString().Split(',');
this.drpSize.DataBind(); this.drpColor.Items.Insert(0, new ListItem("=请选择颜色=", "0"));
this.drpSize.Items.Insert(0, new ListItem("=请选择尺寸=", "0")); }
{
int pid = int.Parse(this.Request.QueryString["pid"].ToString());
DataRow row = pro.getoneproduct(pid);
this.productnameliteral.Text = row["productname"].ToString();
this.ltProductorders.Text = row["productorders"].ToString();
this.IMG1.Src = "pic/" + row["imagepath"].ToString();
this.IMG1.Alt = "pic/" + row["imagepath"].ToString();
this.type_1nameliteral.Text = t_1.gettypename(int.Parse(row["typeid_1"].ToString()));
this.type_2nameliteral.Text = t_2.gettypename(int.Parse(row["typeid_2"].ToString()));
this.pointcountliteral.Text = row["pointcount"].ToString();
this.countliteral.Text = (int.Parse(row["count"].ToString()) > int.Parse(row["sellcount"].ToString())) ? row["count"].ToString() : "缺货";
this.sellcountliteral.Text = row["sellcount"].ToString();
this.priceliteral.Text = row["price"].ToString();
this.userpriceliteral.Text = row["userprice"].ToString();
this.specialsliteral.Text = row["specialsprice"].ToString();
this.descriptionliteral.Text = row["description"].ToString();
this.drpColor.DataSource = row["pcolor"].ToString().Split(',');
this.drpColor.DataBind(); this.drpSize.DataSource = row["psize"].ToString().Split(',');
this.drpSize.DataBind(); this.drpColor.Items.Insert(0, new ListItem("=请选择颜色=", "0"));
this.drpSize.Items.Insert(0, new ListItem("=请选择尺寸=", "0")); }
this.drpColor.Items.Insert(0, new ListItem("=请选择颜色=", "0"));
this.drpSize.Items.Insert(0, new ListItem("=请选择尺寸=", "0"));
这2句没必要写,你只要直接在drpColor、drpSize控件里分别添加"=请选择颜色="、"=请选择尺寸="2个项,但是要把dropdownlist的AppendDataBoundItems属性改成true就可以了,2005新增的功能
this.drpColor.DataBind(); row["pcolor"].ToString() 这个值是什么?
如果 string s = "a,b,c,d,e,f"; 这样就没问题
但如果string s = "a,b,c,d,e,f,";这样就会多出一个空项,你只要把最好一个,去掉就可以了代码:s = s.TrimEnd(',');