当为gridview设置数据源时,一切正常,并且可以完美显示我的表并可以正常连接。设置完数据源并进入设计视图后,它会正确显示我的列标题,但查询中的数据不再存在。
最后,在浏览器中调试后,页面完全空白。没有gridview,没有表,只有一个空白页。我想知道我需要什么代码才能显示在网页上,以及确保显示我查询的任何示例数据。
每个教程我都看他们做的和我做的完全一样,只是当他们在浏览器中查看表和数据时。我确实注意到,在DataSource中编写查询后,它使查询大大改变了。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="Assetmvc.Test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True" DataKeyNames="EmployeeId,id,ItemId,Expr3,ModelID,CompSerial,PhoneSerial,TabletSerial,PrinterSerial,DockSerial,BoosterSerial,SleeveSerial,GloveSerial" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="EmployeeId" HeaderText="EmployeeId" ReadOnly="True" SortExpression="EmployeeId" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="HiredDate" HeaderText="HiredDate" SortExpression="HiredDate" />
<asp:BoundField DataField="FiredDate" HeaderText="FiredDate" SortExpression="FiredDate" />
<asp:BoundField DataField="CurrentItems" HeaderText="CurrentItems" SortExpression="CurrentItems" />
<asp:BoundField DataField="SupervisorId" HeaderText="SupervisorId" SortExpression="SupervisorId" />
<asp:BoundField DataField="SupervisorName" HeaderText="SupervisorName" SortExpression="SupervisorName" />
<asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" />
<asp:BoundField DataField="Expr1" HeaderText="Expr1" SortExpression="Expr1" />
<asp:BoundField DataField="Expr2" HeaderText="Expr2" SortExpression="Expr2" />
<asp:BoundField DataField="JobID" HeaderText="JobID" SortExpression="JobID" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
<asp:BoundField DataField="ItemId" HeaderText="ItemId" ReadOnly="True" SortExpression="ItemId" />
<asp:BoundField DataField="ItemType" HeaderText="ItemType" SortExpression="ItemType" />
<asp:BoundField DataField="DateAssigned" HeaderText="DateAssigned" SortExpression="DateAssigned" />
<asp:BoundField DataField="ManifactureId" HeaderText="ManifactureId" SortExpression="ManifactureId" />
<asp:CheckBoxField DataField="Disposed" HeaderText="Disposed" SortExpression="Disposed" />
<asp:BoundField DataField="ReturnDate" HeaderText="ReturnDate" SortExpression="ReturnDate" />
<asp:BoundField DataField="Expr3" HeaderText="Expr3" ReadOnly="True" SortExpression="Expr3" />
<asp:BoundField DataField="ManifactureName" HeaderText="ManifactureName" SortExpression="ManifactureName" />
<asp:BoundField DataField="ModelName" HeaderText="ModelName" SortExpression="ModelName" />
<asp:BoundField DataField="ModelID" HeaderText="ModelID" ReadOnly="True" SortExpression="ModelID" />
<asp:BoundField DataField="Expr4" HeaderText="Expr4" SortExpression="Expr4" />
<asp:BoundField DataField="CompSerial" HeaderText="CompSerial" ReadOnly="True" SortExpression="CompSerial" />
<asp:BoundField DataField="ManifacturerID" HeaderText="ManifacturerID" SortExpression="ManifacturerID" />
<asp:BoundField DataField="Model" HeaderText="Model" SortExpression="Model" />
<asp:BoundField DataField="OperatingSystem" HeaderText="OperatingSystem" SortExpression="OperatingSystem" />
<asp:BoundField DataField="WarrantyEnd" HeaderText="WarrantyEnd" SortExpression="WarrantyEnd" />
<asp:BoundField DataField="HDSize" HeaderText="HDSize" SortExpression="HDSize" />
<asp:BoundField DataField="PhoneSerial" HeaderText="PhoneSerial" ReadOnly="True" SortExpression="PhoneSerial" />
<asp:BoundField DataField="ServiceProvider" HeaderText="ServiceProvider" SortExpression="ServiceProvider" />
<asp:CheckBoxField DataField="TelogisOnly" HeaderText="TelogisOnly" SortExpression="TelogisOnly" />
<asp:BoundField DataField="Expr5" HeaderText="Expr5" SortExpression="Expr5" />
<asp:BoundField DataField="PhoneNum" HeaderText="PhoneNum" SortExpression="PhoneNum" />
<asp:BoundField DataField="Expr6" HeaderText="Expr6" SortExpression="Expr6" />
<asp:BoundField DataField="TabletSerial" HeaderText="TabletSerial" ReadOnly="True" SortExpression="TabletSerial" />
<asp:BoundField DataField="Expr7" HeaderText="Expr7" SortExpression="Expr7" />
<asp:CheckBoxField DataField="Expr8" HeaderText="Expr8" SortExpression="Expr8" />
<asp:BoundField DataField="Expr9" HeaderText="Expr9" SortExpression="Expr9" />
<asp:BoundField DataField="Expr10" HeaderText="Expr10" SortExpression="Expr10" />
<asp:BoundField DataField="PrinterSerial" HeaderText="PrinterSerial" ReadOnly="True" SortExpression="PrinterSerial" />
<asp:BoundField DataField="Expr11" HeaderText="Expr11" SortExpression="Expr11" />
<asp:BoundField DataField="Expr12" HeaderText="Expr12" SortExpression="Expr12" />
<asp:BoundField DataField="DockSerial" HeaderText="DockSerial" ReadOnly="True" SortExpression="DockSerial" />
<asp:BoundField DataField="Expr13" HeaderText="Expr13" SortExpression="Expr13" />
<asp:BoundField DataField="Expr14" HeaderText="Expr14" SortExpression="Expr14" />
<asp:BoundField DataField="BoosterSerial" HeaderText="BoosterSerial" ReadOnly="True" SortExpression="BoosterSerial" />
<asp:BoundField DataField="Expr15" HeaderText="Expr15" SortExpression="Expr15" />
<asp:BoundField DataField="Expr16" HeaderText="Expr16" SortExpression="Expr16" />
<asp:BoundField DataField="SleeveSerial" HeaderText="SleeveSerial" ReadOnly="True" SortExpression="SleeveSerial" />
<asp:BoundField DataField="IssueDate" HeaderText="IssueDate" SortExpression="IssueDate" />
<asp:BoundField DataField="ExpireDate" HeaderText="ExpireDate" SortExpression="ExpireDate" />
<asp:BoundField DataField="SleeveStatus" HeaderText="SleeveStatus" SortExpression="SleeveStatus" />
<asp:BoundField DataField="GloveSerial" HeaderText="GloveSerial" InsertVisible="False" ReadOnly="True" SortExpression="GloveSerial" />
<asp:BoundField DataField="GloveStatus" HeaderText="GloveStatus" SortExpression="GloveStatus" />
<asp:BoundField DataField="Size" HeaderText="Size" SortExpression="Size" />
<asp:BoundField DataField="Expr17" HeaderText="Expr17" SortExpression="Expr17" />
<asp:BoundField DataField="Expr18" HeaderText="Expr18" SortExpression="Expr18" />
<asp:BoundField DataField="Note" HeaderText="Note" SortExpression="Note" />
<asp:BoundField DataField="Expr19" HeaderText="Expr19" SortExpression="Expr19" />
<asp:BoundField DataField="Expr20" HeaderText="Expr20" SortExpression="Expr20" />
<asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AssetTrackingConnectionString3 %>" SelectCommand="SELECT Employees.EmployeeId, Employees.FirstName, Employees.LastName, Employees.HiredDate, Employees.FiredDate, Employees.CurrentItems, Employees.SupervisorId, Employees.SupervisorName, Job.id, Job.SupervisorID AS Expr1, Job.SupervisorName AS Expr2, Job.JobID, Job.City, Job.State, Items.ItemId, Items.ItemType, Items.DateAssigned, Items.ManifactureId, Items.Disposed, Items.ReturnDate, Manifacturer.ManifactureID AS Expr3, Manifacturer.ManifactureName, Models.ModelName, Models.ModelID, Models.ManifactureID AS Expr4, Computers.CompSerial, Computers.ManifacturerID, Computers.Model, Computers.OperatingSystem, Computers.WarrantyEnd, Computers.HDSize, Phones.PhoneSerial, Phones.ServiceProvider, Phones.TelogisOnly, Phones.ModelId AS Expr5, Phones.PhoneNum, Phones.ManifactureID AS Expr6, Tablets.TabletSerial, Tablets.ServiceProvider AS Expr7, Tablets.TelogisOnly AS Expr8, Tablets.ModelId AS Expr9, Tablets.Phonenum AS Expr10, Printers.PrinterSerial, Printers.ManifactureID AS Expr11, Printers.Model AS Expr12, Docks.DockSerial, Docks.WarrantyEnd AS Expr13, Docks.ManifactureID AS Expr14, CellBoosters.BoosterSerial, CellBoosters.ManifacturerID AS Expr15, CellBoosters.Model AS Expr16, Sleeves.SleeveSerial, Sleeves.IssueDate, Sleeves.ExpireDate, Sleeves.SleeveStatus, Gloves.GloveSerial, Gloves.GloveStatus, Gloves.Size, Gloves.IssueDate AS Expr17, Gloves.ExpireDate AS Expr18, Notes.Note, Notes.EmployeeID AS Expr19, Notes.ItemId AS Expr20, Notes.Date FROM Employees CROSS JOIN Job CROSS JOIN Items CROSS JOIN Manifacturer CROSS JOIN Models CROSS JOIN Computers CROSS JOIN Phones CROSS JOIN Tablets CROSS JOIN Printers CROSS JOIN Docks CROSS JOIN CellBoosters CROSS JOIN Sleeves CROSS JOIN Gloves CROSS JOIN Notes"></asp:SqlDataSource>
</div>
</form>
</body>
</html>