CS0236: 字段初始值设定项无法引用非静态字段、方法或属性“_Default.str”

编译错误

说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: CS0236: 字段初始值设定项无法引用非静态字段、方法或属性“_Default.str”

源错误:

行 15:     public string str;

行 16:     string l_ProductSer = "select ID ,CN_CLASS as P_Name from CLASS";

行 17:     string   l_Product = "select P_ID,P_Name,left(P_Content,150) as P_Content,P_Picture from CN_PRODUCT where P_ClassID='" + str+"'";

行 18:     int pg;

行 19:     public static int ps_page;


源文件: e:\0615\shengfeng\web\cn\Product\FrmProduct_Class.aspx.cs    行: 17
解决办法:

    public string str;
    string l_ProductSer = "select ID ,CN_CLASS as P_Name from CLASS";
    string   l_Product;
    int pg;
    public static int ps_page;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //str = Request.QueryString["receive"].ToString();
            str = Request.QueryString[0].ToString();
            l_Product = "select P_ID,P_Name,left(P_Content,150) as P_Content,P_Picture from CN_PRODUCT where P_ClassID='" + str+"'";
            loaderDate();
        }
    }

你可能感兴趣的:(方法)