我正在尝试为我的项目创建一种模板,它只是我需要的几个类似页面的主要内容(不是母版页,也不是用户控件)。
我对 asp.net 和 HTML 很陌生,所以我相信你们可以帮助我。
我想要实现的模式看起来像这样(这是在油漆中做的,请原谅):
在底部有我正在尝试构建的表单的部分代码(它现在只有上部网格视图和详细信息视图),但您可以在我拍摄的屏幕截图中看到我的问题(删除的行有个人数据):网格视图(和详细信息视图)低于“第二个中心字幕”。如何根据gridview中的行数保留空行?我可以在不丢失数据的情况下为 gridview 设置最大行数吗?
我还添加了用于此表单的 css 文件的一部分。
谢谢!
.aspx
文件(主要内容-在主代码之后):
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="maincontent2headers">Create New Sale</div>
<div><br /> </div>
<div class="maincontent2leftsubtitles" > Select customer </div>
<div class="maincontent2rightsubtitles"> Custumer's Details </div>
<br />
<br />
<div class="floatleft">
<asp:GridView ID="SelectCustomerGridView" runat="server"
AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="Customer_ID" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None"
AllowSorting="True">
<AlternatingRowStyle BackColor="White"
ForeColor="#284775" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="Customer_ID"
HeaderText="Customer_ID" ReadOnly="True"
SortExpression="Customer_ID" />
<asp:BoundField DataField="First_Name"
HeaderText="First_Name" SortExpression="First_Name" />
<asp:BoundField DataField="Last_Name"
HeaderText="Last_Name" SortExpression="Last_Name" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Customer_ID], [First_Name], [Last_Name] FROM [Customers]">
</asp:SqlDataSource>
</div>
<div class="floatright">
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px"
Width="125px" AutoGenerateRows="False" CellPadding="4"
DataKeyNames="Customer_ID" DataSourceID="SqlDataSource2"
ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White"
ForeColor="#284775" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<EditRowStyle BackColor="#999999" />
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<Fields>
<asp:BoundField DataField="Customer_ID"
HeaderText="Customer_ID" ReadOnly="True"
SortExpression="Customer_ID" />
<asp:BoundField DataField="First_Name"
HeaderText="First_Name" SortExpression="First_Name" />
<asp:BoundField DataField="Last_Name"
HeaderText="Last_Name" SortExpression="Last_Name" />
<asp:BoundField DataField="Phone" HeaderText="Phone"
SortExpression="Phone" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:BoundField DataField="eMail" HeaderText="eMail"
SortExpression="eMail" />
</Fields>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
</asp:DetailsView>
</div>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Customers] WHERE ([Customer_ID] = @Customer_ID)">
<SelectParameters>
<asp:ControlParameter ControlID="SelectCustomerGridView"
DefaultValue="NULL" Name="Customer_ID"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
<div class="maincontent2centeredsubtitles">
second subtitle here</div>
<br />
<div>
<div class="floatleft">put here to float to the left</div>
<div class="floatright">put here to float to the right</div>
</div>
<br />
<center>place to show the results (delete the center tags)</center>
<br />
<br />
<div >
<center>buttons to proceed (delete the canter tags)</center>
</div>
<br />
<div>
</div>
</asp:Content>
css
与此代码有关的部分内容:
.floatleft
{
float:left;
margin-left:5px;
margin-right:5px;
}
.floatright
{
float:right;
margin-right:5px;
margin-left:5px;
}
.maincontent2headers
{
font-family: 'Arial Black';
font-size: xx-large;
color: #465767;
text-align: center;
vertical-align: middle;
margin-bottom: 0px;
width:auto;
}
.maincontent2centeredsubtitles
{
font-family: 'Arial Black';
font-size: small;
color: #465767;
text-align: center;
vertical-align: middle;
}
.maincontent2leftsubtitles
{
font-family: 'Arial Black';
font-size: small;
color: #465767;
float:left;
margin-left:5px;
margin-right:5px;
}
.maincontent2rightsubtitles
{
font-family: 'Arial Black';
font-size: small;
color: #465767;
float:right;
margin-left:5px;
margin-right:5px;
}
.centeredtext
{
text-align:center;
}