472,143 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

DataBinder.Eval Error!


Subject: DataBinder.Eval Error!

Server Error in '/MSPOS' Application.

------------------------------------------------------------------------
--------

DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a
property with the name REPORTTO.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinder.Eval:
'System.Data.Common.DbDataRecord' does not contain a property with the
name REPORTTO.
Please email me at mc*****@sun.net.bb
I have done the following:
1) Modified my datagrid:
<asp:TemplateColumn HeaderText="Reports To">
<ItemTemplate>
<%# Convert.ToString(DataBinder.Eval(Container.DataIte m, "REPORTTO")) %>
</ItemTemplate>
<FooterTemplate>
<asp:DropdownList id="insertReportTos" DataSource='<%# BindUserNames()
%>' DataTextField="REPORTTO" DataValueField="REPORTTOID" runat="server">
</asp:DropdownList>
</FooterTemplate>
<EditItemTemplate>
<asp:DropdownList runat="server" id="ddlReportTos" DataSource='<%#
BindUserNames() %>' DataTextField="REPORTTO" DataValueField="REPORTTOID"
selectedindex='<%#
GetSelectedIndexReportsTo(DataBinder.Eval(Containe r.DataItem,
"REPORTTO").ToString())%>'>
</asp:DropdownList>
</EditItemTemplate>
</asp:TemplateColumn>

Now in my datagrid

SELECT USERID,REPORTTOID,USERNAME,GetUserName(REPORTTOID) AS REPORTTO
FROM TBUSERS

With the above SQL statement. Now I must incorporate it in the
datagrid.
private DataSet BindUserNames()
{
// Populate the ddlDataSet
OdbcConnection myConnection = new
OdbcConnection("DSN=POS;UID=system;PWD=system");
myConnection.Open();
const string strSQLDDL = @"SELECT
USERID,REPORTTOID,USERNAME,GetUserName(REPORTTOID) AS REPORTTO FROM
TBUSERS";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(strSQLDDL,
myConnection);
ddlDataSet3.Clear();
myDataAdapter.Fill(ddlDataSet3, "ddlReportTos");
myDataAdapter.Dispose();
myDataAdapter = null;
// In next 2 lines, Dispose removes connection string info, Close is
better.
// Use one or the other, but not both...
// myConnection.Dispose();
myConnection.Close();
return ddlDataSet3;
}
But then I get this error when I run the program:

Server Error in '/MSPOS' Application.
------------------------------------------------------------------------
--------

DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a
property with the name REPORTTO.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinder.Eval:
'System.Data.Common.DbDataRecord' does not contain a property with the
name REPORTTO.

Source Error:
Line 567: <asp:TemplateColumn HeaderText="Reports To">
Line 568: <ItemTemplate>
Line 569: <asp:Label id="lblReporTo" Runat="server" Text='<%#
Convert.ToString(DataBinder.Eval(Container.DataIte m,"REPORTTO")) %>'>
Line 570: </asp:Label>
Line 571: </ItemTemplate>
Source File: C:\Inetpub\wwwroot\MSPOS\Administrators.aspx Line: 569

Stack Trace:
[HttpException (0x80004005): DataBinder.Eval:
'System.Data.Common.DbDataRecord' does not contain a property with the
name REPORTTO.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName) +147
System.Web.UI.DataBinder.Eval(Object container, String[]
expressionParts) +71
System.Web.UI.DataBinder.Eval(Object container, String expression)
+82
ASP.Administrators_aspx.__DataBind__control50(Obje ct sender,
EventArgs e) in C:\Inetpub\wwwroot\MSPOS\Administrators.aspx:569
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.Control.DataBind() +26
System.Web.UI.Control.DataBind() +86
System.Web.UI.Control.DataBind() +86
System.Web.UI.WebControls.DataGrid.CreateItem(Int3 2 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object
dataItem, DataGridColumn[] columns, TableRowCollection rows,
PagedDataSource pagedDataSource) +169
System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource) +1411
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e) +49
System.Web.UI.WebControls.BaseDataList.DataBind() +23
ASP.Administrators_aspx.BindData() in
C:\Inetpub\wwwroot\MSPOS\Administrators.aspx:153
ASP.Administrators_aspx.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\MSPOS\Administrators.aspx:38
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
0 3643

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Søren Lund | last post: by
2 posts views Thread by jack | last post: by
2 posts views Thread by Oleg Ogurok | last post: by
1 post views Thread by Nathan Sokalski | last post: by
2 posts views Thread by Lam | last post: by
4 posts views Thread by CharlesA | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.