我有一个 asp.net 项目和 2 个表:
报告
RegisterID EventID UserID DateTime
用户
用户 ID 用户名
现在我想要一个显示日期时间和用户名的网格视图。
我从 2 小时开始尝试这个,但没有一次机会展示这个。
怎么做?
直到现在我有这个:
public static List<EventRegistration> GetAllRegistrationsForEventID(Guid eventID)
{
using (CyberDBDataContext db = new CyberDBDataContext())
{
DataLoadOptions options = new DataLoadOptions();
options.LoadWith<EventRegistration>(p => p.CyberUser);
db.LoadOptions = options;
List<EventRegistration> list = (from a in db.EventRegistrations where a.EventID == eventID select a).ToList();
return list;
}
和这个:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetAllRegistrationsForEventID"
TypeName="DAL.RegistrationHandler">
<SelectParameters>
<asp:QueryStringParameter DbType="Guid" DefaultValue="0000-000000-000000-0000" Name="eventID"
QueryStringField="id" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1"
EmptyDataText="Keine Spieler registriert"
onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="RegisterID" HeaderText="RegisterID" SortExpression="RegisterID"
Visible="false" />
<asp:BoundField DataField="EventID" HeaderText="EventID" SortExpression="EventID"
Visible="false" />
<asp:TemplateField HeaderText='Name' ItemStyle-HorizontalAlign='Center'>
<ItemTemplate>
<asp:Label ID="lblName" runat="server" Text="Label"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Timestamp" HeaderText="Anmeldezeit" SortExpression="Timestamp" />
<asp:BoundField DataField="UserID" HeaderText="UserID" SortExpression="UserID" />
</Columns>
</asp:GridView>
但没有任何效果