C# id键未显示在listview中
我试图在我的listview中显示DoctorId键字段,它总是显示为空白C# id键未显示在listview中,c#,asp.net,listview,C#,Asp.net,Listview,我试图在我的listview中显示DoctorId键字段,它总是显示为空白 <asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' /> 这是.aspx页面 <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="AppointementD
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
这是.aspx页面
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="AppointementDataContext" EnableDelete="True" EnableInsert="True"
EnableUpdate="True" EntityTypeName="" TableName="Appointement"
Where="IsAvailable = True && dateApt >= DateTime.Now && doctorId = Doctor.Id &&
doctorid = 1">
<WhereParameters>
<asp:ControlParameter
Name="doctor_name"
ControlID="DropDownList1"
PropertyName="SelectedValue"
Type="String" />
</WhereParameters>
</asp:LinqDataSource>
<asp:ListView ID="ListView1" runat="server" DataKeyNames="aptId"
DataSourceID="LinqDataSource1" InsertItemPosition="LastItem" >
<AlternatingItemTemplate>
<tr style="">
<td>
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
</td>
<td>
<asp:Label ID="DoctorNameLabel" runat="server"
Text='<%# Eval("Doctor.Doctor_Name") %>' />
</td>
<td>
<asp:Label ID="dateAptLabel" runat="server"
Text='<%# Eval("dateApt", "{0:dd/MM/yyyy}") %>' />
</td>
<td>
<asp:Label ID="hourAptLabel" runat="server"
Text='<%# Eval("hourApt", @"{0:hh\:mm}") %>' />
</td>
<td>
<asp:CheckBox id="MyCheckBox" runat="server"
value='<%# Eval("aptId") %>'
AutoPostBack="true"
OnCheckedChanged="Check_Clicked" />
</td>
</tr>
</AlternatingItemTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
</td>
<td>
<asp:Label ID="DoctorNameLabel" runat="server"
Text='<%# Eval("Doctor.Doctor_Name") %>' />
</td>
<td>
<asp:Label ID="dateAptLabel" runat="server"
Text='<%# Eval("dateApt", "{0:dd/MM/yyyy}") %>' />
</td>
<td>
<asp:Label ID="hourAptLabel" runat="server"
Text='<%# Eval("hourApt", @"{0:hh\:mm}") %>' />
</td>
<td>
<asp:CheckBox id="MyCheckBox" runat="server"
value='<%# Eval("aptId") %>'
AutoPostBack="true"
OnCheckedChanged="Check_Clicked" />
</td>
</tr>
</ItemTemplatee>
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
除了doctorID之外,所有字段都具有正确的值
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
这是我的任命
public partial class Doctor : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new
PropertyChangingEventArgs(String.Empty);
private int _Id;
private string _Doctor_name;
private EntitySet<Appointement> _Appointement;
public partial class Appointement : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new
PropertyChangingEventArgs(String.Empty);
private int _aptId;
private System.Nullable<int> _clientId;
private int _doctorId;
private System.DateTime _dateApt;
private System.TimeSpan _hourApt;
private System.Nullable<bool> _IsAvailable;
private EntityRef<Doctor> _Doctor;
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
公共部分类医生:INotifyPropertyChanged,INotifyPropertyChanged
{
私有静态属性ChangingEventArgs emptyChangingEventArgs=new
PropertyChangingEventArgs(String.Empty);
私人内部Id;
私有字符串\u医生\u姓名;
私人实体集(U)任命;
公共部分类任命:INotifyPropertyChanged,INotifyPropertyChanged
{
私有静态属性ChangingEventArgs emptyChangingEventArgs=new
PropertyChangingEventArgs(String.Empty);
私人互联网;
private System.Nullable_clientId;
私人国际博士学位;
private System.DateTime\u dateApt;
private System.TimeSpan\u hourApt;
私有系统。可为空—可用;
私人实体主任医生;
医生的名字出来了,所以它以某种方式连接正确。我不明白为什么doctorId或doctor.Id没有显示在列表视图上
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
下面是如何定义appointment.dbml的:
任命表(aptId、clientId、doctorId、dateApt、hourApt、IsAvailable)
医生表(Id、医生姓名)
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
我注意到在appoiment.aspx的设计模式中,我的DoctorId列没有显示在DataBound中。你知道如何使用DataBound吗
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
谢谢不知为什么我删除了表定义
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
我在定义的末尾移动了它们,它起作用了
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
如果它能在未来帮助任何人
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />