Subject: DataBinder.Eval Error!
Server Error in '/MSPOS' Application.
------------------------------------------------------------------------
--------
DataBinder.Eval : 'System.Data.Co mmon.DbDataReco rd' 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.Http Exception: DataBinder.Eval :
'System.Data.Co mmon.DbDataReco rd' 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:TemplateCo lumn HeaderText="Rep orts To">
<ItemTemplate >
<%# Convert.ToStrin g(DataBinder.Ev al(Container.Da taItem, "REPORTTO") ) %>
</ItemTemplate>
<FooterTemplate >
<asp:DropdownLi st id="insertRepor tTos" DataSource='<%# BindUserNames()
%>' DataTextField=" REPORTTO" DataValueField= "REPORTTOID " runat="server">
</asp:DropdownLis t>
</FooterTemplate>
<EditItemTempla te>
<asp:DropdownLi st runat="server" id="ddlReportTo s" DataSource='<%#
BindUserNames() %>' DataTextField=" REPORTTO" DataValueField= "REPORTTOID "
selectedindex=' <%#
GetSelectedInde xReportsTo(Data Binder.Eval(Con tainer.DataItem ,
"REPORTTO").ToS tring())%>'>
</asp:DropdownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
Now in my datagrid
SELECT USERID,REPORTTO ID,USERNAME,Get UserName(REPORT TOID) 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=sy stem;PWD=system ");
myConnection.Op en();
const string strSQLDDL = @"SELECT
USERID,REPORTTO ID,USERNAME,Get UserName(REPORT TOID) AS REPORTTO FROM
TBUSERS";
OdbcDataAdapter myDataAdapter = new OdbcDataAdapter (strSQLDDL,
myConnection);
ddlDataSet3.Cle ar();
myDataAdapter.F ill(ddlDataSet3 , "ddlReportTos") ;
myDataAdapter.D ispose();
myDataAdapter = null;
// In next 2 lines, Dispose removes connection string info, Close is
better.
// Use one or the other, but not both...
// myConnection.Di spose();
myConnection.Cl ose();
return ddlDataSet3;
}
But then I get this error when I run the program:
Server Error in '/MSPOS' Application.
------------------------------------------------------------------------
--------
DataBinder.Eval : 'System.Data.Co mmon.DbDataReco rd' 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.Http Exception: DataBinder.Eval :
'System.Data.Co mmon.DbDataReco rd' does not contain a property with the
name REPORTTO.
Source Error:
Line 567: <asp:TemplateCo lumn HeaderText="Rep orts To">
Line 568: <ItemTemplate >
Line 569: <asp:Label id="lblReporTo " Runat="server" Text='<%#
Convert.ToStrin g(DataBinder.Ev al(Container.Da taItem,"REPORTT O")) %>'>
Line 570: </asp:Label>
Line 571: </ItemTemplate>
Source File: C:\Inetpub\wwwr oot\MSPOS\Admin istrators.aspx Line: 569
Stack Trace:
[HttpException (0x80004005): DataBinder.Eval :
'System.Data.Co mmon.DbDataReco rd' does not contain a property with the
name REPORTTO.]
System.Web.UI.D ataBinder.GetPr opertyValue(Obj ect container, String
propName) +147
System.Web.UI.D ataBinder.Eval( Object container, String[]
expressionParts ) +71
System.Web.UI.D ataBinder.Eval( Object container, String expression)
+82
ASP.Administrat ors_aspx.__Data Bind__control50 (Object sender,
EventArgs e) in C:\Inetpub\wwwr oot\MSPOS\Admin istrators.aspx: 569
System.Web.UI.C ontrol.OnDataBi nding(EventArgs e) +66
System.Web.UI.C ontrol.DataBind () +26
System.Web.UI.C ontrol.DataBind () +86
System.Web.UI.C ontrol.DataBind () +86
System.Web.UI.W ebControls.Data Grid.CreateItem (Int32 itemIndex, Int32
dataSourceIndex , ListItemType itemType, Boolean dataBind, Object
dataItem, DataGridColumn[] columns, TableRowCollect ion rows,
PagedDataSource pagedDataSource ) +169
System.Web.UI.W ebControls.Data Grid.CreateCont rolHierarchy(Bo olean
useDataSource) +1411
System.Web.UI.W ebControls.Base DataList.OnData Binding(EventAr gs e) +49
System.Web.UI.W ebControls.Base DataList.DataBi nd() +23
ASP.Administrat ors_aspx.BindDa ta() in
C:\Inetpub\wwwr oot\MSPOS\Admin istrators.aspx: 153
ASP.Administrat ors_aspx.Page_L oad(Object sender, EventArgs e) in
C:\Inetpub\wwwr oot\MSPOS\Admin istrators.aspx: 38
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +67
System.Web.UI.C ontrol.LoadRecu rsive() +35
System.Web.UI.P age.ProcessRequ estMain() +750
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!