【发布时间】:2012-09-12 10:43:43
【问题描述】:
我有一个绑定到 ObjectDataSoure 的 Gridview。
ObjectDataSource 使用调用 DAL 方法的业务对象,该方法返回 DataTable 和查询结果。
应用程序在运行时工作,但在设计时有一个问题: 当我使用 GridView 的任务向导 -> 编辑列时:没有字段出现在选定字段文本区域中(所以我不能使用向导来编辑列)。
DAL 方法:
public override DataTable GetAllWorkers()
{
using (SqlConnection con = new SqlConnection(this.ConnectionString)) {
SqlCommand cmd = new SqlCommand("t_Workers_GetAllWorkers", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
return GetTable(cmd);
}
}
private DataTable GetTable(SqlCommand cmd)
{
SqlDataAdapter adp = new SqlDataAdapter();
adp.SelectCommand = cmd;
DataTable dt = new DataTable();
adp.Fill(dt);
return dt;
}
BLL 方法:
public static DataTable GetAllWorkers()
{
return DataProvider.Instance().GetAllWorkers();
}
ASPX 网页:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetAllWorkers" TypeName="BLL.BizImpl"></asp:ObjectDataSource>
<asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1"
EnableModelValidation="True" Height="156px" Width="270px">
</asp:GridView>
有人能解释一下问题的原因吗?
Thanks
【问题讨论】:
标签: c# asp.net data-binding gridview objectdatasource