zoukankan      html  css  js  c++  java
  • 今天工作中遇到的根据用户id取得产品大类和相关小类的问题

    今天做了一个项目,需求是客户登陆后,可以从会员中心发布详细信息(包括联系信息和公司信息),插入到数据库后在将来生成一个公司页面模板,一般的产品大类+小类

    用repeater嵌套就可以了,但是这个涉及到某个用户发布某几个产品大类+小类,首先根据登陆的session("userid"),从产品表中取得产品大类id,,一个session("userid")能发布多个产品,代码如下:

    private void bindSWDaLei()
    {
    //暂时先绑定上所有信息??
    int uid = 1;//临时

    DataTable dt = Class1.ExecSel("select distinct p_b_ID from product where p_UserID=" + uid + "");

    string getids = "";
    if (dt != null && dt.Rows.Count > 0)
    {
    for (int i = 0; i < dt.Rows.Count; i++)
    {


    getids += dt.Rows[i]["p_b_ID"].ToString() + ",";


    }
    getids = getids.Substring(0, getids.Length - 1);
    string strSql = "select * from Class where Menu_ID in (" + getids + ")";
    DataTable dtDL = Class1.ExecSel(strSql);
    RpDL.DataSource = dtDL;
    RpDL.DataBind();


    }


    }

     getids += dt.Rows[i]["p_b_ID"].ToString() + ",";

    string strSql = "select * from Class where Menu_ID in (" + getids + ")";

    这里的用法很关键,自己以后工作中要注意

  • 相关阅读:
    learning scala view collection
    scala
    learning scala dependency injection
    learning scala implicit class
    learning scala type alise
    learning scala PartialFunction
    learning scala Function Recursive Tail Call
    learning scala Function Composition andThen
    System.Threading.Interlocked.CompareChange使用
    System.Threading.Monitor的使用
  • 原文地址:https://www.cnblogs.com/wanshutao/p/4283856.html
Copyright © 2011-2022 走看看