zoukankan      html  css  js  c++  java
  • 代码错误集合(全是低级错误,欢迎高手前来指教)

    Q:vs.net2003中的控件的某些事件代码会莫名其妙的丢失,如
             this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
    A:不知道为什么,高手指教
    -----
    Q:qing
    A:
    Q:DataGrid的删除事件等不起作用了
     A:郁闷,把EnableVviewState属性改为True
    -----
    Q:把if(Request.Params["id"].Tostring()!=string.Empty){},在URL后面没有ID参数的时候出现错误
    A: if(Request["id"]!=null){}
    -----
    Q:  public class temp()
          {
               int shopID = Convert.ToInt32(Session["shopID"]); 
               ...
               public function(){}
           }    
        非静态的字段、方法或属性“System.Web.UI.Page.Session”要求对象引用
    A: public class temp()
          {
               ...
               public function(){
                 int shopID = Convert.ToInt32(Session["shopID"]); 
                }
           }   
    -------
    Q:如何绑定数据到DropDownList?
    A:this.DropDownListTag.DataSource= ds.Tables[0].DefaultView;
        this.DropDownListTag.DataTextField = "name";
        this.DropDownListTag.DataValueField = "id";
        this.DropDownListTag.DataBind();
       //为其赋值
       this.DropDownListClass.SelectedValue = ds.Tables[0].Rows[0]["类别"].ToString().Trim();
    -----
    Q:替换函数
    A:name=name.Replace("'","\"");
    -----
    Q:取最新添加的用户的ID
    A:string strSql = "INSERT INTO users(email,name,pwd) VALUES('" + email + "','" +name+ "','" + pwd+ "');" ;
          strSql = strSql + "SELECT @@identity AS 'identity'";
    -----
    Q:判断SqlDataReader中有无数据
    A:if(reader.Read()) //Read()方法,如果存在多个行,则为 true;否则为 false
       {
        int temp = Convert.ToInt32(reader[0]);
        reader.Close(); //注意关闭
        return temp;    
       }
       else
       {
        reader.Close();
        return -1;    
       }

    其他待更新
  • 相关阅读:
    topcoder srm 320 div1
    topcoder srm 325 div1
    topcoder srm 330 div1
    topcoder srm 335 div1
    topcoder srm 340 div1
    topcoder srm 300 div1
    topcoder srm 305 div1
    topcoder srm 310 div1
    topcoder srm 315 div1
    如何统计iOS产品不同渠道的下载量?
  • 原文地址:https://www.cnblogs.com/lbk/p/376056.html
Copyright © 2011-2022 走看看