單擊
http://develop
圖
DataGrid控件用來向用戶展示已有的產品信息
private void Page_Load(object sender
{
if(Session[
{
//獲得數據庫連接字符串
string STconnection = ConfigurationSettings
STconn = new SqlConnection(STconnection);
if(!IsPostBack)
{
//自定義BindGrid ()方法
BindGrid();
}
}
else
{
Response
}
}
public void BindGrid()
{
//創建查詢產品信息的sql語句
string STstrsql=
//根據上面的sql語句
SqlDataAdapter da=new SqlDataAdapter(STstrsql
//創建DataSet的實例
DataSet ds=new DataSet();
//將信息填充到DataSet
da
//獲取數據源
STmyGrid
//將信息綁定到DataGrid
STmyGrid
}
right
From:http://tw.wingwit.com/Article/program/net/201311/15653.html