| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 411 人关注过本帖
标题:一个很邪门的问题,如有明白的请不吝赐教
只看楼主 加入收藏
libai_6
Rank: 1
等 级:新手上路
帖 子:3
专家分:5
注 册:2010-5-10
收藏
 问题点数:0 回复次数:1 
一个很邪门的问题,如有明白的请不吝赐教


图中A区,是商品分类列表,B区会根据A区的选择自动加载此分类的所有商品。A区和B区都是根据数据库内容自动生成。点击B区的商品名称,会在下面显示此商品的详细信息,其中C就是显示此商品的类别选项。C的内容也是根据数据库得到。

现在说,这个很邪门的问题出在哪里?

说明一下,点击C,会产生桌面回发事件。我想通过改变C的选项内容,通过点击下面的按钮(更新产品信息),更改此产品所属的类别。

如果在B区里,选择的如果不是第一个商品,下面显示的也是此商品的详细信息,此时可以改变C的内容,如果在B的里面选择的是第一个商品,此时C的内容即使点了,经过桌面回发事件以后,还是会回到原来的状态!请各位高手不吝赐教,原因到底出在哪里?多谢
图片附件: 游客没有浏览图片的权限,请 登录注册
一切问题都来根据此图说明。

搜索更多相关主题的帖子: 不吝 
2010-05-10 21:14
libai_6
Rank: 1
等 级:新手上路
帖 子:3
专家分:5
注 册:2010-5-10
收藏
得分:0 

以下为后台代码
public partial class ProductManage : System.Web.UI.Page
    {
        string imagename;
        bool updatesuc;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!IsPostBack)
            {
                //加载商品大类名称
                DataBase db = new DataBase();
                string sql = "select * from producttype";
                DataTable dt = db.GetDataTable(sql);
                DDLbigtype.DataSource = dt;
                DDLbigtype.DataValueField = "pt_id";
                DDLbigtype.DataTextField = "pt_name";
                DDLbigtype.DataBind();
                //加载产品小类列表
                DataBase dbxiao = new DataBase();
                string sqlxiao = "select * from productt";
                DataTable dtxiao = db.GetDataTable(sqlxiao);
                DDLsmalltype.DataSource = dtxiao;
                DDLsmalltype.DataValueField = "pt_sid";
                DDLsmalltype.DataTextField = "pts_name";
                DDLsmalltype.DataBind();
                //加载默认图片
                Imgproduct.ImageUrl = "~/productimage/moren.jpg";
            }
            //根据商品大类加载商品小类
            JIAZAIxl(Convert.ToInt32(DDLbigtype.SelectedValue));
         //根据商品小类加载产品
            if (Session["pmtid"] != null)
            {
                JIAZAIchanpin(Convert.ToInt32(Session["pmtid"]));
            }
            
        }
        //加载产品小类信息
        private void JIAZAIxl(int dalei)
        {
            DataBase dbtype = new DataBase();
            string sqltype = "select * from productt where pts_b=" + dalei;
            DataTable dttype = dbtype.GetDataTable(sqltype);
            if (dttype.Rows.Count > 0)
            {
                RadioButton[] rdb = new RadioButton[dttype.Rows.Count];
                for (int i = 0; i < dttype.Rows.Count; i++)
                {
                    rdb = new RadioButton();
                    rdb.Text = dttype.Rows["pts_name"].ToString();
                    rdb.ID = dttype.Rows["pt_sid"].ToString();
                    rdb.GroupName = "type";
                    rdb.AutoPostBack = true;
                    rdb.CheckedChanged += new EventHandler(rdb_CheckedChanged);
                    Panelsmalltype.Controls.Add(rdb);
                }
            }
        }  
  //加载产品信息
        private void JIAZAIchanpin(int xiaolei)
        {
           
            this.PanelPINFO.Controls.Clear();
            DataBase db = new DataBase();
            string sql = "select * from product where product_t=" + xiaolei;
            DataTable dt = db.GetDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                this.PanelPINFO.Controls.Clear();
                RadioButton[] rpn = new RadioButton[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    rpn = new RadioButton();
                    rpn.Text = dt.Rows["product_n"].ToString();
                    rpn.ID = "p" + dt.Rows["product_id"].ToString();
                    rpn.GroupName = "pro";
                    rpn.AutoPostBack = true;
                    rpn.CheckedChanged += new EventHandler(rpn_CheckedChanged);
                    PanelPINFO.Controls.Add(rpn);
                }
            }
        }
        //点击商品小类别选项
        private void rdb_CheckedChanged(object sender, EventArgs e)
        {            RadioButton rb = (RadioButton)sender;
            Session["pmtid"] = rb.ID;
            JIAZAIchanpin(Convert.ToInt32(Session["pmtid"]));
        }
        //点击商品名称
        private void rpn_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = (RadioButton)sender;
            Session["pmpid"] = rb.ID.ToString().Substring(1);
            DataBase db = new DataBase();
            string sql = "select * from product_info where product_id=" + Convert.ToInt32(Session["pmpid"]);
            DataTable dt = db.GetDataTable(sql);
            DDLsmalltype.SelectedValue = dt.Rows[0]["product_t"].ToString();
            Txtcount.Text = dt.Rows[0]["product_count"].ToString();
            Txtpdescribe.Text = dt.Rows[0]["product_d"].ToString();
            Txtpname.Text = dt.Rows[0]["product_n"].ToString();
            Txtsellprice.Text = dt.Rows[0]["product_sell_price"].ToString();
            Imgproduct.ImageUrl = dt.Rows[0]["product_i"].ToString();
            Txtyjcount.Text = dt.Rows[0]["product_yjcount"].ToString();
            
        }
        protected void DDLbigtype_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["pmtid"] = null;
            Session["pmpid"] = null;
            Panelsmalltype.Controls.Clear();
            PanelPINFO.Controls.Clear();
            JIAZAIxl(Convert.ToInt32(DDLbigtype.SelectedValue));
            
        }

        //上传添加图片
        protected void UpdateImage()
        {
            }
        //对产品信息进行更新
        protected void BtnUpdate_Click(object sender, EventArgs e)
        {
            Productcs pcs = new Productcs();
            pcs.productname = Txtpname.Text.ToString();
            pcs.productid = Convert.ToInt32(Session["pmpid"]);
            pcs.productt =Convert .ToInt32 (DDLsmalltype .SelectedValue );
            pcs.product_sellp =Convert .ToInt32 (Txtsellprice .Text.ToString ());
            pcs.product_yj = Convert.ToInt32(Txtyjcount.Text.ToString());
            pcs.producti = "~/productimage/" + Session["pmpid"].ToString() + ".jpg";
            pcs.productd = Txtpdescribe.Text.ToString();
            if (FUimage.FileName != "")
            {
                try
                {
                    string fileadress = Server.MapPath("~//productimage//") + Session["pmpid"].ToString() + ".jpg";
                    File.Delete(fileadress);
                }
                catch { }
                imagename = Session["pmpid"].ToString();
                UpdateImage();
            }
            bool suc = pcs.UpdateProduct(pcs);
            if (suc)
            {
                Session["pmpid"] = null;
                Session["pmtid"] = null;
                Response.Write("<script>alert('商品信息更新成功!');window.location.href ='productmanage.aspx'</script>");
            }
            else
            {
            }
        }
        
         
    }
2010-05-10 21:15
快速回复:一个很邪门的问题,如有明白的请不吝赐教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017261 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved