【发布时间】:2012-01-18 21:35:58
【问题描述】:
我正在构建一个页面来显示带有分页的客户端数据的 GridView。我的 aspx 页面有一个 GridView,其 DataSourceID 设置为 ObjectDataSource。 ObjectDataSource 绑定到 BLL,而 BLL 又通过 DAL 访问数据。在指向静态数据库的同时,我已经启动并运行了整个过程。但是,每个客户的数据都存储在自己的数据库中。下一步是根据客户端登录修改DAL的ConnectionString。
我已将 DAL TableAdapter 配置为选项 ConnectionModifier 设置为“公共”。我的 BLL 可以修改 DAL 的连接字符串,但是我不知道如何将客户端数据库名称传递给 BLL。
public class PDFDocumentsBLL {
private PDFTableAdapter _pdfdocumentsadapter = null;
protected PDFTableAdapter Adapter {
get {
if ( _pdfdocumentsadapter == null ) {
_pdfdocumentsadapter = new PDFTableAdapter();
_pdfdocumentsadapter.Connection = new System.Data.SqlClient.SqlConnection(
ConfigurationManager.ConnectionStrings["template"].ConnectionString.Replace( "TEMPLATE", "TESTCLIENT" )
);
}
return _pdfdocumentsadapter;
}
}
...
}
我想用一个变量替换上面代码中的字符串“TESTCLIENT”,但是我不知道如何将这个信息传递给 BLL。
【问题讨论】:
标签: c# pagination connection objectdatasource