页面效果
imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
cs页面代码
protected void Page_Load(object sender, EventArgs e)
{
//数据库地址
string sqlPath = "server =; database =; uid =; pwd =";
//创建数据库对象
SqlConnection con = new SqlConnection(sqlPath);
//数据库命令
string sqlcmd = "select xm,xb,pxdd from userlist order by id";
//执行sql语句
SqlDataAdapter sqlda = new SqlDataAdapter(sqlcmd,con);
//创建Dataset对象
DataSet dataSet = new DataSet();
//填充数据集
sqlda.Fill(dataSet);
//绑定数据
GridView1.DataSource = dataSet;
GridView1.DataBind();
}
aspx页面代码
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
</div>
</form>
</body>