对齐asp.net Web应用程序的页面控件

时间:2011-02-08 19:18:29

标签: asp.net css controls

我正在尝试在tabcontainer的一个tabpanel上设置一个带有数据网格和图表的Web应用程序。它开始没问题,但我需要将图表放在数据网格旁边。我读到了关于使用css但无法使用它。 我添加了一个单独的css文件

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<link type="text/css" rel="stylesheet" href="defaultStyle.css"/>

...

<asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
                AutoGenerateColumns="False" BackColor="White" BorderColor="#336666" 
                BorderStyle="Double" BorderWidth="3px" CellPadding="4" 
                DataSourceID="SqlDataSource1" GridLines="Horizontal" Height="92px" 
                Width="327px" HorizontalAlign="Right">
<RowStyle BackColor="White" ForeColor="#333333" HorizontalAlign="Right" />
        <PagerStyle HorizontalAlign="Center" BackColor="#336666" ForeColor="White" /> 
                <Columns>
                    <asp:BoundField DataField="RecordsCount" HeaderText="RecordsCount" 
                        ReadOnly="True" SortExpression="RecordsCount"/>
                    <asp:BoundField DataField="collectionDate" HeaderText="collectionDate" 
                        ReadOnly="True" SortExpression="collectionDate" />
                </Columns>
                <FooterStyle BackColor="White" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
             </asp:GridView>

2 个答案:

答案 0 :(得分:1)

将每个(网格和图表)包装在自己的DIV元素中。

根据需要使用top / leftfloat css属性设置样式DIV。您可能还需要让margin参与其中以获得您想要的外观。

答案 1 :(得分:1)

将控件包裹在div中并将它们浮动到左侧。完成后一定要清除浮子。

<div style="float:left;">
    <!-- Insert GridView -->
</div>
<div style="float:left;">
    <!-- Insert Chart Control -->
</div>
<div style="clear:both;" />