关闭

商品无限及分类部分代码

标签: datasetstring输入法up
815人阅读 评论(0) 收藏 举报
分类:
/// <summary>
                /// 页面初始化绑定所属栏目方法
                /// </summary>
                /// <param name="e"></param>
                private void BindSubjectID()
                {
                        if(dtMC.Rows.Count>0)
                        {
                                foreach(DataRow row in dtMC.Rows)
                                {
                                        if(row["ParentID"].ToString().Trim()=="0")
                                        {
                                                this.dropXYSPZL.Items.Add(new ListItem(row["Name"].ToString(),row["ProductClass_ID"].ToString()));
                                                this.BindDropChildItems(this.dropXYSPZL,dtMC,row["ProductClass_ID"].ToString(),1);
                                        }
                                }
                               
                                //设置首选项。
                                this.dropXYSPZL.Items.Insert(0,new ListItem("添加新种类","0"));
                        }
                }               

                /// <summary>
                /// 绑定DataTable的方法
                /// </summary>
                private void MCFillDT()
                {
                        SF_Public.SQLHelp sqlhelp=new SanFeng.SF_Public.SQLHelp();
                        SqlParameter[] para={};
                        DataSet mydata=sqlhelp.getDataSet("UP_ProductClass_GetList",para,"SPZL");
                        dtMC=mydata.Tables[0];
                }

                /// <summary>
                /// 绑定子节点
                /// </summary>
                /// <param name="drop"></param>
                /// <param name="dt"></param>
                /// <param name="id"></param>
                /// <param name="length"></param>
                private void BindDropChildItems(DropDownList drop,DataTable dtMC,string id,int length)
                {
                        DataRow[] rows=dtMC.Select("ParentID='"+id+"'","ProductClass_ID desc");
                        for(int i=0;i<rows.Length;i++)
                        {
                                this.dropXYSPZL.Items.Add(new ListItem(this.SpaceLength(length)+rows[i]["Name"].ToString(),rows[i]["ProductClass_ID"].ToString()));
                                this.BindDropChildItems(drop,dtMC,rows[i]["ProductClass_ID"].ToString(),length+1);
                        }

                }
               
                /// <summary>
                /// 子栏目前的空白
                /// </summary>
                /// <param name="i"></param>
                /// <returns></returns>
                private string SpaceLength(int i)
                {
                        string space="";
                        for(int j=0;j<i;j++)
                        {
                                space+=" ";//注意这里的空白是智能abc输入法状态下的v11字符;
                        }
                        return space;
                }
                #endregion




 /// <summary>
                /// 页面初始化绑定所属栏目方法
                /// </summary>
                /// <param name="e"></param>
                private void BindSubjectID()
                {
                        if(dtMC.Rows.Count>0)
                        {
                                foreach(DataRow row in dtMC.Rows)
                                {
                                        if(row["ParentID"].ToString().Trim()=="0")
                                        {
                                                this.dropXYSPZL.Items.Add(new ListItem(row["Name"].ToString(),row["ProductClass_ID"].ToString()));
                                                this.BindDropChildItems(this.dropXYSPZL,dtMC,row["ProductClass_ID"].ToString(),1);
                                        }
                                }
                               
                                //设置首选项。
                                this.dropXYSPZL.Items.Insert(0,new ListItem("添加新种类","0"));
                        }
                }               

                /// <summary>
                /// 绑定DataTable的方法
                /// </summary>
                private void MCFillDT()
                {
                        SF_Public.SQLHelp sqlhelp=new SanFeng.SF_Public.SQLHelp();
                        SqlParameter[] para={};
                        DataSet mydata=sqlhelp.getDataSet("UP_ProductClass_GetList",para,"SPZL");
                        dtMC=mydata.Tables[0];
                }

                /// <summary>
                /// 绑定子节点
                /// </summary>
                /// <param name="drop"></param>
                /// <param name="dt"></param>
                /// <param name="id"></param>
                /// <param name="length"></param>
                private void BindDropChildItems(DropDownList drop,DataTable dtMC,string id,int length)
                {
                        DataRow[] rows=dtMC.Select("ParentID='"+id+"'","ProductClass_ID desc");
                        for(int i=0;i<rows.Length;i++)
                        {
                                this.dropXYSPZL.Items.Add(new ListItem(this.SpaceLength(length)+rows[i]["Name"].ToString(),rows[i]["ProductClass_ID"].ToString()));
                                this.BindDropChildItems(drop,dtMC,rows[i]["ProductClass_ID"].ToString(),length+1);
                        }

                }
               
                /// <summary>
                /// 子栏目前的空白
                /// </summary>
                /// <param name="i"></param>
                /// <returns></returns>
                private string SpaceLength(int i)
                {
                        string space="";
                        for(int j=0;j<i;j++)
                        {
                                space+=" ";//注意这里的空白是智能abc输入法状态下的v11字符;
                        }
                        return space;
                }
                #endregion

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:3891次
    • 积分:48
    • 等级:
    • 排名:千里之外
    • 原创:0篇
    • 转载:4篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档