-----------------------------DAL----------------------------------------------------
public List select(int UserID)
{
//初始化數據庫連接對象
DateAccessLaye dbmyfile = new DateAccessLaye();
//初始化myfilemodel對象的集合實例
DataTable dsmf = dbmyfile.GetDataTable("SELECT Title,FSize,Checkcode,Uploadtime FROM myfile WHERE UserID=" + UserID);
List mfm = new List();
foreach (DataRow dr in dsmf.Rows)
{
myfilemodel mfmd=new myfilemodel();
mfmd.Title = dr["Title"].ToString();
mfmd.FSize = (float)System.Convert.ToDouble(dr["FSize"].ToString());
mfmd.Checkcode = dr["Checkcode"].ToString();
mfmd.Uploadtime = Convert.ToDateTime(dr["Uploadtime"]);
mfm.Add(mfmd);
}
return mfm;
}
---------------------------------------BLL-------------------------------------
public class myfilebll
{
public List select(int UserID)
{
myfiledal mf = new myfiledal();
return mf.select(UserID);
}
}
-----------------------------UI---------------------------------------------------
protected void Button8_Click(object sender, EventArgs e)
{
int s = 0;
s = Convert.ToInt32(TextBox1.Text);
GridView gv = new GridView();
myfilebll mf = new myfilebll();
gv.DataSource = mf.select(s);
gv.DataBind();
}
運行時GridView沒有顯示
1、實現在頁面添加GridView控件
2、動態添加GridView控件到頁面
this.Controls.Add(gv);