如何在数据GridView中绑定数据?
问题描述:
我开发了一个售书员应用程序.过期后在数据库中订阅的客户显示在数据网格"视图中.
Hi,
I am developed one Book Seller Application.In data Base after date expire Subscribed Customers display in Data Grid view. How to Display the Data Grid view.?
答
关注链接:
在具有搜索功能的GridView中显示数据 [ ^ ]
这个很好! [
Follow the links:
Display Data in GridView with Search Functionality[^]
This one is Good[^]
我认为此代码项目文章可能也有帮助
用于从DataBase和使用反射将DataTable保存到数据库中 [
I think this Code Project article may also be helpful
General purpose class to fill DataTable(s) from DataBase and to save DataTable(s) to DataBase using reflection[^]
表格:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
public void Bind()
{
setConnectionString();
query = "select * from userinfo";
//Session["GridView1"] = EmpBal.bindgridBAL(query, conString);
DataSet ds = EmpBal.bindgridBAL(query, conString);
GridView1.DataSource = ds;
GridView1.DataBind();
}
数据层:
Data Layer:
public DataSet bindgridDAL(string query, string conString)
{
try
{
SqlDataAdapter da = new SqlDataAdapter(query,conString);
ds = new DataSet();
da.Fill(ds, "EmpDetail");
da.Dispose();
}
catch (Exception ex)
{
throw ex;
}
return ds;
}
它适用于三层体系结构.
业务层:
it is for 3 tier architecture.
Business layer:
Public DataSet bindgridBAL(string query, string conString)
{
try
{
return empDAL.bindgridDAL(query, conString);
}
catch (Exception ex)
{
throw ex;
}
}