2011-10-12

 购物车写了两天了,我却还在皮毛之中,老师讲的东西从逻辑上讲我很明白,可是讲到实际每段代码能实现什么功能、有什么具体含义,我还是知之甚少、、、

所以购物车,制鞋到了这个地步、、、

 protected void Page_Load(object sender, EventArgs e)
    {
        TableRow row = new TableRow();
        TableCell cell = new TableCell();
        cell.Text = "商品名";
        row.Cells.Add(cell);
        cell = new TableCell();
        cell.Text = "价格";
        row.Cells.Add(cell);
        cell = new TableCell();
        cell.Text = "图片";
        row.Cells.Add(cell);
        cell = new TableCell();
        cell.Text = "";
        row.Cells.Add(cell);
        Table1.Rows.Add(row);
        string str = ConfigurationManager.ConnectionStrings["jizhu"].ConnectionString;
        SqlConnection sqlcnn = new SqlConnection(str);
        SqlCommand sqlcmm = new SqlCommand();
        sqlcmm.Connection = sqlcnn;
        sqlcmm.CommandText = "select *from goods";
        sqlcnn.Open();
        SqlDataReader read = sqlcmm.ExecuteReader();
        row = new TableRow();
        TableCell cells = new TableCell();
        object[] value = new object[read.FieldCount];
        while (read.Read())
        {
            row = new TableRow();
            cells = new TableCell();
            read.GetValues(value);
            cells.Text = value[1].ToString();
            row.Cells.Add(cells);
            cells=new TableCell ();
            cells.Text = value[2].ToString();
            row.Cells.Add(cells);
            cells = new TableCell();
            Image img = new Image();
            img.ImageUrl = value[3].ToString();
            img.Height = 100;
            img.Width = 60;
            cells.Controls.Add(img);
            row.Cells.Add(cells);
            cells = new TableCell();
            Button btn = new Button();
            btn.Text = "购买";
            cells.Controls.Add(btn);
            row.Cells.Add(cells);
            Table1.Rows.Add(row);
        }
        read.Close();
        sqlcnn.Close();
    }

阅读更多
想对作者说点什么? 我来说一句

小红伞p版key有效期2011-10-12

2011年05月07日 686B 下载

UE(UltraEdit-32)最新中文版

2011年10月24日 22.36MB 下载

彩虹好天气

2013年10月24日 457KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭