ID键没有显示在列表视图了 [英] id key not showing up in listview
问题描述
我想在我的列表视图显示DoctorId关键领域,它总是会说出空白。
I am trying to display the DoctorId key field in my listview and it's coming out always with blanks.
下面是.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正确的价值观。
All the fields are coming out with the proper values EXCEPT the doctorID.
下面是我的Appointement.designer.cs
Here is my 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;
医生的名字叫出来,因此以某种方式连接正确。我不明白为什么没有被显示在列表视图的doctorId或Doctor.Id。
The doctor Name is coming out so it is somehow connected properly. I don't see why the doctorId or the Doctor.Id is not been displayed on the Listview.
下面是Appointement.dbml是如何定义:
Appointement表(aptId,客户端ID,doctorId,dateApt,hourApt,IsAvailable)
医生表(ID,doctor_name)
Here is how the Appointement.dbml is define: Appointement Table (aptId,clientId,doctorId,dateApt,hourApt,IsAvailable) Doctor Table (Id,doctor_name)
我注意到了我的Appointement.aspx列DoctorId没有显示与数据绑定起来的设计模式。关于如何使用数据绑定有任何想法?
I noticed in the Design mode for the Appointement.aspx my column DoctorId is not showing up with DataBound. any idea on how to have it with DataBound ?
感谢
推荐答案
不知何故,我不知道为什么我删除表TD定义
somehow I don't know why I deleted the table td definition
<asp:Label ID="lblDoctorId" runat="server" Value='<%# Eval("doctorId") %>' />
和我搬到他们在定义的末尾和它的作品!
and I moved them at the end of the definition and it works !!!
如果它可以帮助其他人在未来...
If it can help anyone else in the future...
这篇关于ID键没有显示在列表视图了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!