在.net后台cs文件中select查询语句前台老说找不到数据源
DataBinding:“System.Data.DataRowView”不包含名为“ui_desc”的属性。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Web.HttpException: DataBinding:“System.Data.DataRowView”不包含名为“ui_desc”的属性。
源错误:
行 85: <HeaderStyle ForeColor="black" Width="200" />
行 86: <ItemTemplate>
行 87: <asp:Label ID="Label2" runat="server" Text='<%# Bind("ui_desc") %>' />
行 88: </ItemTemplate>
行 89: </asp:TemplateField>
源文件: e:\web\oa\yjgl\fajx.aspx 行: 87
堆栈跟踪:
[HttpException (0x80004005): DataBinding:“System.Data.DataRowView”不包含名为“ui_desc”的属性。]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +197
System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts) +79
System.Web.UI.DataBinder.Eval(Object container, String expression) +108
System.Web.UI.TemplateControl.Eval(String expression) +120
ASP.oa_yjgl_fajx_aspx.__DataBinding__control24(Object sender, EventArgs e) in e:\web\oa\yjgl\fajx.aspx:87
System.Web.UI.Control.OnDataBinding(EventArgs e) +99
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +206
System.Web.UI.Control.DataBind() +12
System.Web.UI.Control.DataBindChildren() +216
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
System.Web.UI.Control.DataBind() +12
System.Web.UI.Control.DataBindChildren() +216
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
System.Web.UI.Control.DataBind() +12
System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +221
System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +2957
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +59
System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +11
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +111
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
hkoa.oa.yjgl.fajx.GridViewBind() in D:\we\we\oa\yjgl\fajx.aspx.cs:67
hkoa.oa.yjgl.fajx.Page_Load(Object Sender, EventArgs E) in D:\we\we\oa\yjgl\fajx.aspx.cs:41
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
public void GridViewBind()
{
string str1 = " fsr='" + Request.Cookies["hyyc"].Values["hyid_carol"].ToString() + "' and lx='f' and scbz='0'";
//检索未删除、发送类型的当前用户的邮件
switch (jsfa.SelectedValue)
{
case "重要":
str1 = str1 + " and zyx='重要'";
break;
case "普通":
str1 = str1 + " and zyx='普通'";
break;
}
AspNetPager1.RecordCount = (int)Socut.Data.ExecuteScalar("select count(*) as nums from oa_mail" + str1);
DataSet ds = Socut.Data.ExecuteDataSet("select id,zt,jsr,ui_desc,bt,fjbz,fssj,zyx from oa_mail a left outer join yh b on (a.jsr=b.ui_id) " + str1 + " order by fssj desc", AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize); ***** ui_desc是yh表的字段,其他都是oa_mail的字段,奇怪的是我增加oa_mail表中其他字段时候前台相应修改的话是正常的,改在yh表中的ui_desc就找不到数据源
GridView1.DataSource = ds;
GridView1.DataBind();
// select oa_mail.id,oa_mail.zt,oa_mail.jsr,yh.ui_desc,oa_mail.bt,oa_mail.fjbz,oa_mail.fssj,oa_mail.zyx from oa_mail,yh where oa_mail.jsr=yh.ui_id and******这句是我自己写的并在数据库中查询过是可以查询出我想要的内容,但是放到程序中仍旧不行。
}
这个ui_desc字段一直就是说找不到。请问是哪里不对了,这问题拖了很久了,请大大们务必帮忙看看,不知道存在什么问题。是查询有问题还是说程序配置有问题,
[解决办法]
select oa_mail.id,oa_mail.zt,oa_mail.jsr,yh.ui_desc as ui_desc,oa_mail.bt,oa_mail.fjbz,oa_mail.fssj,oa_mail.zyx from oa_mail,yh where oa_mail.jsr=yh.ui_id and******
[解决办法]
用事件探查器跟踪一下,把执行的sql语句考出来执行一下,看会不会出错,