C# 如何水平对齐多个Gridview控件?

C# 如何水平对齐多个Gridview控件?,c#,asp.net,webforms,C#,Asp.net,Webforms,我希望有两个或多个控件(例如gridview控件)水平对齐。 可选:我希望在同一行中有1个gridview控件和1个图像控件(水平) 我尝试了以下控件 MultiView: Only vertical alignment possible WebPartZone: It looked good in design mode, but gave me an error (something with the App_Data folder) and I think there must

我希望有两个或多个控件(例如gridview控件)水平对齐。
可选:我希望在同一行中有1个gridview控件和1个图像控件(水平)

我尝试了以下控件

  MultiView: Only vertical alignment possible  
  WebPartZone: It looked good in design mode, but gave me an error (something with the App_Data folder) and I think there must be a more simple approach.  

我可以有两个水平的图像控件。但是为什么不能有两个GridView呢?

试着将它们作为两个单独的div。。。。大概是这样的:

<div style="float:left; position:relative;">
    <asp:GridView ID="GridView1" runat="server">
    </asp:GridView>
</div>
<div style="float:right; position:relative;">
    <asp:GridView ID="GridView2" runat="server">
    </asp:GridView>
</div>

尝试将它们作为两个单独的div。。。。大概是这样的:

<div style="float:left; position:relative;">
    <asp:GridView ID="GridView1" runat="server">
    </asp:GridView>
</div>
<div style="float:right; position:relative;">
    <asp:GridView ID="GridView2" runat="server">
    </asp:GridView>
</div>

您好,请检查此项


希望这对你有帮助。

嗨,请检查一下这张卡片


希望对您有所帮助。

尝试按照mikeshorts提到的将网格视图放在Div中,或者使用另一种方式,如use table

<table>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server">
    </asp:GridView>
</td>
<td>
<asp:GridView ID="GridView2" runat="server">
    </asp:GridView>
</td>
</tr>
</table>

或者您只需使用horizontallign属性,如

<asp:GridView ID="GridView1" runat="server"  HorizontalAlign="Left" >
    </asp:GridView>
    <asp:GridView ID="GridView2" runat="server"  HorizontalAlign="Right" >
    </asp:GridView>


我希望它能为您工作。

尝试按照mikeshorts提到的将网格视图放在Div中,或者使用另一种方式,如use table

<table>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server">
    </asp:GridView>
</td>
<td>
<asp:GridView ID="GridView2" runat="server">
    </asp:GridView>
</td>
</tr>
</table>

或者您只需使用horizontallign属性,如

<asp:GridView ID="GridView1" runat="server"  HorizontalAlign="Left" >
    </asp:GridView>
    <asp:GridView ID="GridView2" runat="server"  HorizontalAlign="Right" >
    </asp:GridView>


我希望它对您有用。

+1感谢您的回答,它非常有用,是第一个成功的解决方案。不知道float:left thing.+1谢谢你的回答,它很有用,是第一个成功的解决方案。不知道浮动:左边的东西。表格解决方案是我需要的。谢谢。我有4个网格,如何安排2个在上面,2个在下一行。表格解决方案是我需要的。谢谢。我有4个网格,如何安排2个在上面,2个在下一排