ASP.NET WebForm后台如何给GridView控件绑定数据

应该算是一个很简单的问题,但是有些人还是用的到的


代码比较简单,大概就是这些

​
protected void Page_Load(object sender, EventArgs e)
        {
            string constr = "Data Source=服务器;Initial Catalog=数据库;Persist Security Info=True;User ID=shwip;Password=shwip";
            string sql = "SELECT APiece.Piece_PId,APiece.Piece_Id,APiece.Piece_Level FROM APiece";
            SqlConnection coon = new SqlConnection(constr);
            SqlDataAdapter sda = new SqlDataAdapter(sql, coon);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }

​

想要需要进一步调整样式修改表格背景颜色的参考下一篇文章

猜你喜欢

转载自blog.csdn.net/qq_42450386/article/details/85157076