我正在尝试在列表视图中显示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>
所有字段都以适当的值出现,除了doctorID。
这是我的Appointement.designer.cs
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;
医生名字出来所以它以某种方式正确连接。我不明白为什么在Listview上没有显示doctorId或Doctor.Id。
以下是Appointement.dbml的定义方式: Appointement表(aptId,clientId,doctorId,dateApt,hourApt,IsAvailable) 医生表(Id,doctor_name)
我注意到在Appointement.aspx的设计模式下,我的专栏DoctorId没有显示DataBound。关于如何使用DataBound的任何想法?
由于
答案 0 :(得分:0)
不知怎的,我不知道为什么我删除了表td定义
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
我在定义的最后移动它们并且它有效!
如果它可以在将来帮助其他人......