................. using System.Data.SqlClient;
public partial class product_product : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindData(); } }
public void BindData() { Conn conn = new Conn(); SqlConnection con = conn.getConn(); SqlDataAdapter sda = new SqlDataAdapter("select * from product", con); DataSet ds = new DataSet(); sda.Fill(ds); //填充数据集 GridView1.DataSource = ds; GridView1.DataBind(); conn.Close(); } ................ }
|