DataBinding:'System.Data.DataRowView'不包含名为'p'的属性

时间:2014-11-04 13:31:37

标签: asp.net vb.net

我收到错误DataBinding:“'System.Data.DataRowView'在以下代码中的一个查询中不包含名为'p'的属性”。 它在这一行显示错误:

  <asp:Label ID="lblPharmName" runat="server" Text='<%# String.Format("{0} {1}", Eval("p.Pharm_fname"), Eval("p.Pharm_lname")) %>'>
                </asp:Label> 

以下是代码。但我怀疑使用的查询。任何建议将在查找导致错误返回的原因时受到赞赏。 谢谢

 <%@ Page Language="VB" MasterPageFile="~/CIOSMasterNonAuth.master" AutoEventWireup="false" CodeFile="ViewOrders.aspx.vb" Inherits="ViewOrders" title="Untitled Page" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<%--<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>--%>
<asp:Table runat="server" Font-Size="Small" HorizontalAlign="Center">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">
<asp:Label runat="server">Order Status: </asp:Label>
</asp:TableCell>
<asp:TableCell HorizontalAlign="Left">
<asp:DropDownList ID="OrderStatusDropDownList" runat="server" AutoPostBack="True">
     <asp:ListItem Text="Verified" Value="V" />
     <asp:ListItem Text="New" Value="N" />
     <asp:ListItem Text="Cancelled" Value="C" />
</asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="2">
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<HeaderTemplate>
            <table border="1" visible="false">
                <tr>
                    <th>
                        Web Order ID
                    </th>
                    <th>
                        Web Entry Date
                    </th>
                    <th>
                        Protocol Number
                    </th>
                    <th>
                        Site Number
                    </th>
                    <th>
                        Pharmacist of Record
                    </th>
                </tr>
         </HeaderTemplate>
         <ItemTemplate>
            <tr>
                <td>
                    <asp:LinkButton runat="server" ID="lnkOrderDetails" Text='<%# Eval("web_order_id") %>' OnClick="lnkOrderDetails_Click" />
                </td>
                <td>
                    <asp:Label ID="lblWebEntryDate" runat="server" Text='<%# Eval("web_entry_date") %>'>
                    </asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblProtocolNum" runat="server" Text='<%# Eval("protocol_num") %>'>
                    </asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblSiteNum" runat="server" Text='<%# Eval("site_num") %>'>
                    </asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblPharmName" runat="server" Text='<%# String.Format("{0} {1}", Eval("p.Pharm_fname"), Eval("p.Pharm_lname")) %>'>
                    </asp:Label>                        
                </td>

            </tr>
         </ItemTemplate>
         <FooterTemplate>
            </table>
        </FooterTemplate>
     </asp:Repeater>
     </asp:TableCell>
     </asp:TableRow>
  </asp:Table>

 <asp:Button runat="server" ID="btnShowModalPopup" style="display:none"/>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="btnShowModalPopup"
 PopupControlID="divPopUp" 
PopupDragHandleControlID="panelDragHandle">
</cc1:ModalPopupExtender>

<div id="divPopUp" style="display:none; font-family:Georgia; font-size:small;">
 <asp:Panel runat="Server" ID="panelDragHandle" BackColor="#009999" BorderColor="ActiveBorder"  BorderStyle="Ridge" ForeColor="White" Width="800px">
 <table width="100%">
 <tr>
 <td>
     Hold here to Drag this Box
    </td>
    <td align="right">
 <asp:Label runat="server" ID="lblText" Text="Web OrderID: " ForeColor="White"></asp:Label>

 <asp:Label ID="lblWebOrderID" runat="server"></asp:Label>
 </td>
 </tr>
 <tr>
 <td colspan="2"> 
 <asp:GridView ID="GridView2" runat="server" BackColor="#FFFFCC" ForeColor="Black" AutoGenerateColumns="False" Width="100%" >

 <Columns>
 <asp:BoundField DataField="line_id" HeaderText="Line Item"/>
 <asp:BoundField DataField="no_of_participants" HeaderText="Number of Participants" />
 <asp:BoundField DataField="amt_inventory" HeaderText="Current Inventory"/>
 <asp:BoundField DataField="nsc_num" HeaderText="NSC number"/>
 <asp:BoundField DataField="drug_name" HeaderText="Drug name"/>
 <asp:BoundField DataField="dose_str" HeaderText="Dose Strength"/>
 <asp:BoundField DataField="dose_unit" HeaderText="Dose Unit"/>
 <asp:BoundField DataField="dose_form_comment" HeaderText="Dose Form"/>
 <asp:BoundField DataField="dose_mult" HeaderText="Dose Mult" />
 <asp:BoundField DataField="amt_req" HeaderText="Amt Required"/>
 </Columns>
 </asp:GridView> 
 </td> 
 </tr>
 <tr> 
 <td colspan="2" align="right">                       
<asp:Button ID="btnClose" runat="server" Text="Close" />
</td>
</tr>
</table>
</asp:Panel>
 <br />

     </div>
       <% 
    Response.AddHeader("Refresh", "60")
   %>

  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CIOSConnectionString3 %>" 


      SelectCommand="SELECT w.web_order_id, w.web_entry_date, w.site_num, w.protocol_num, w.inv_num, w.pharm_num, w.status, w.Comments, w.UserName, w.porStatus, p.Pharm_fname + ' ' + p.Pharm_lname AS 'PharmName' FROM Web_Shipping AS w INNER JOIN Pharmacist_of_record AS p ON p.pharm_num = w.pharm_num WHERE (w.status = @status) ORDER BY w.web_order_id DESC" >
     <SelectParameters>
        <asp:ControlParameter ControlID="OrderStatusDropDownList" Name="Status" 
            PropertyName="Text" Type="Char" />
            </SelectParameters>
    </asp:SqlDataSource>

     <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CIOSConnectionString3 %>" 

    SelectCommand="SELECT Web_Ship_detail.line_id, Web_Ship_detail.no_of_participants, Web_Ship_detail.Amt_inventory, Web_Ship_detail.NSC_num, Web_Ship_detail.Dose_str, Web_Ship_detail.Dose_unit, Web_Ship_detail.Dose_mult, Web_Ship_detail.amt_req, Drug.Drug_name, Dosage_Form.dose_form_comment FROM Web_Ship_detail INNER JOIN Drug ON Web_Ship_detail.NSC_num = Drug.NSC_Num INNER JOIN Dosage_Form ON Web_Ship_detail.Dose_form = Dosage_Form.dose_form WHERE (Web_Ship_detail.web_order_id = @web_order_id) ORDER BY Web_Ship_detail.line_id">
    <SelectParameters>
        <asp:ControlParameter ControlID="lblWebOrderID" Name="web_order_id" 
            PropertyName="Text" Type="Decimal" />
    </SelectParameters>

</asp:SqlDataSource>

1 个答案:

答案 0 :(得分:0)

这些

Eval("p.Pharm_fname"), Eval("p.Pharm_lname")

您的选择

中不存在
p.Pharm_fname + ' ' + p.Pharm_lname AS 'PharmName'

您需要更新您的Eval以评估PharmName或SQL以包含p.Pharm_fname和p.Pharm_lname并删除Eval中的别名引用。