Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2004, 02:35 PM
Authorized User
 
Join Date: Aug 2004
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to macupryk Send a message via Yahoo to macupryk
Default Subject: DataBinder.Eval Error! Datagrid.

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.


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






Knowledge is to be shared.
__________________
Knowledge is to be shared.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Repeater without DataBinder safin ASP.NET 2.0 Professional 1 February 3rd, 2006 12:20 PM
DataBinder Eval in Repeater New2VBnetChic Classic ASP Basics 0 August 18th, 2005 12:44 PM
Databinder.Eval jpfree71 ASP.NET 1.0 and 1.1 Basics 2 August 26th, 2004 11:07 AM
DataBinder.Eval(Container, etc. - Please explain pete_m ASP.NET 1.0 and 1.1 Basics 1 June 25th, 2004 11:52 AM
Error installing SQL2000 Eval chrislepingwell SQL Server 2000 2 June 6th, 2003 11:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.