C#相关知识

1、style

 .style1
        {
            text-align: center;
            font-size: xx-large;
            color:Blue;
            background-color: #A0FFFF;
            width: 80%;
            margin-left: 10%;
            height:650px;
            
        }

2、调用别的模块,比如说登录模块


 

段子


空行

3、datalist


 //模板
   

<%# DataBinder.Eval(Container.DataItem, "id")%>

//数据绑定
       
       


          
               
               

<%# DataBinder.Eval(Container.DataItem, "id")%>  
       


       

       


 

       

       

       

         

       
      


        
         
       

4、连接数据库的类

  public class db
    {
        public static string connstring =
            //@"data source=WIN7-20140423SZ\SQLEXPRESS; Initial Catalog=user_login;integrated security=SSPI";
        @"server=qds148466258.my3w.com;user id=qds148466258;password=huzhenghui119; Initial Catalog=qds148466258_db";
        // @"Data Source=.\SQLEXPRESS;Initial Catalog=WEBSQL;Integrated Security=SSPI";
        public static void DoSql(string sql)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = connstring;
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);
            cmd.ExecuteNonQuery();
            conn.Close();
        }
        public static DataSet GreatDs(string sql)
        {
            SqlConnection myconn = new SqlConnection(connstring.ToString());
            myconn.Open();
            SqlDataAdapter mydr = new SqlDataAdapter(sql, myconn);
            DataSet myds = new DataSet();
            mydr.Fill(myds);
            myconn.Close();
            return myds;
        }
         public void MsgBox(string strMsg, string URL)
    {
        string StrScript;
        StrScript = ("");
        System.Web.HttpContext.Current.Response.Write(StrScript);
    }

5、数据绑定的后台

public partial class ups_china : System.Web.UI.Page
{
    private int CID;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CDataBind();
        }


    }
    private void CDataBind()
    {


        int provice=1,city=1,company=1;
        SqlConnection conn = new SqlConnection(db.connstring.ToString());
        conn.Open();
        string mysql1 = "select * from UPSData where(provice='"+ provice+"' and city='"+city+"' and company='"+company+"')";
        SqlDataAdapter sa = new SqlDataAdapter(mysql1, conn);
        DataSet ds = new DataSet();
        sa.Fill(ds, "table1");
        //处理
        DataTable dtNew = ds.Tables["table1"].Copy();  //复制dt表数据结构
        dtNew.Clear(); //清除数据
        foreach (DataRow mydr in ds.Tables["table1"].Rows)
        {
            dtNew.Rows.Add(mydr.ItemArray);
            //dtNew.Rows.Add(ds.Tables["table1"].Rows[i].ItemArray);
        }
         /*
       for (int i = 0; i < dtNew.Rows.Count; i++)
        {
            dtNew.Rows[i]["id"] = i + 1;
        }
        */
        //绑定数据
        System.Web.UI.WebControls.PagedDataSource ps = new PagedDataSource();
        ps.DataSource = dtNew.DefaultView;
        ps.AllowPaging = true;
        ps.PageSize = 5;
        //ps.CurrentPageIndex = curPage - 1;
        this.DataList1.DataSource = ps;
        this.DataList1.DataBind();
        conn.Close();
            //绑定完毕
            //处理图片
      
    }
}

6、脚本

");
        }
       
        else if(TextBox3.Text!=Session["vcode"].ToString())
        {
            Response.Write("");
        }
        else
        {
            string pu, pw;
            pu = TextBox1.Text.Replace("'", "''");
            pw = TextBox2.Text.Replace("'", "''");
            string sql = "select * from userinfo where usertext='" + pu + "' and userpass='" + pw + "'";
            DataTable dt = new DataTable();
            dt = db.GreatDs(sql).Tables[0];
            if (dt.Rows.Count > 0)
            {
                Response.Write("");
                Session["memberlogin"] = "ok";
                Session["membername"] = pu;
                Session["memberpass"] = pw;
                Response.Redirect("zhuye.aspx");
            }
            else
            {
                Response.Write("");
            }
        }
    }

你可能感兴趣的:(C#)