c# - 为什么asp.net显示表名而不是表字段
问题描述
我正在做一个项目,我正在组合 3 个表,这些表已经在 dbml 中关联,但我的问题是,当我使用数据列表时,它会显示我的表名而不是正确的字段,这是大学作业,但我已经尝试了我所知道的一切做。
我试图在 sql 管理器中将它们单独组合在 vs 但我只是不明白为什么它没有显示正确的东西
<form id="form1" runat="server">
<div>
<asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="assign_6_final.DataClasses1DataContext" EntityTypeName="" Select="new (CustomerID, Name)" TableName="Customers">
</asp:LinqDataSource>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="LinqDataSource1" DataTextField="Name" DataValueField="CustomerID" OnSelectedIndexChanged="Page_Load">
</asp:DropDownList>
<asp:DataList ID="DataList1" runat="server" DataSourceID="LinqDataSource2" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" OnSelectedIndexChanged="DataList1_SelectedIndexChanged" OnDataBinding="DataList1_SelectedIndexChanged">
<ItemTemplate>
IncidentID:
<asp:Label ID="IncidentIDLabel" runat="server" Text='<%# Eval("IncidentID") %>' />
<br />
DateOpened:
<asp:Label ID="DateOpenedLabel" runat="server" Text='<%# Eval("DateOpened") %>' />
<br />
DateClosed:
<asp:Label ID="DateClosedLabel" runat="server" Text='<%# Eval("DateClosed") %>' />
<br />
Title:
<asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
<br />
Description:
<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
<br />
CustomerID:
<asp:Label ID="CustomerIDLabel" runat="server" Text='<%# Eval("CustomerID") %>' />
<br />
Technician:
<asp:Label ID="TechnicianLabel" runat="server" Text='<%# Eval("Technician") %>' />
<br />
Product:
<asp:Label ID="ProductLabel" runat="server" Text='<%# Eval("Product") %>' />
<br />
<br />
<br />
</ItemTemplate>
</asp:DataList>
</div>
<asp:LinqDataSource ID="LinqDataSource2" runat="server" ContextTypeName="assign_6_final.DataClasses1DataContext" EntityTypeName="" Select="new (IncidentID, DateOpened, DateClosed, Title, Description, CustomerID, Technician, Product)" TableName="Incidents" Where="CustomerID = @CustomerID">
<WhereParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CustomerID" PropertyName="SelectedValue" Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
<asp:EntityDataSource ID="EntityDataSource1" runat="server">
</asp:EntityDataSource>
</form>
</body>
我期望的结果是产品和技术人员可以正确输出最后 2 个项目,但他们没有,我有点迷失了我的老师说这是 asp 中的一个常见问题,但我从未见过
解决方案
尝试使用以下等:
<%# DataBinder.Eval(Container.DataItem,"CustomerID") %>
推荐阅读
- ios - 使用远程配置进行 Firebase A/B 测试:添加新参数时,需要排除旧应用版本吗?
- r - excel中的日期清理,日期值左对齐
- scala - run-main-0) scala.ScalaReflectionException:JavaMirror 中的类 java.sql.Date 和 ClasspathFilter(
- python - 获取 sqlalchemy 基类对象而不是子类
- javascript - 角度 - 组件之间的传递函数
- pandas - 为什么删除行出现错误AttributeError:'DataFrame'对象没有属性'No'
- php - 我的客户在工作后更改了仪表板访问权限
- amazon-web-services - AWS CLI S3 获取对象标签
- c - 存储字符/字符串文字的编码是什么?(或者如何从输入中找到字符串中的文字字符?)
- swift - 调用此完成处理程序的正确语法是什么?