C# 对齐GridView下的Asp.net按钮
我有一个GridView,下面有三个按钮。我试图找出如何对齐它们,以便第一个按钮的左边缘与GridView的左边缘对齐,第二个按钮位于GridView下方的中心,第三个按钮的右边缘与GridView的右边缘对齐。如果GridView的宽度扩大,我希望按钮与GridView保持对齐。现在,按钮水平排列在一起,向左对齐。 这是我想要的东西的草图C# 对齐GridView下的Asp.net按钮,c#,asp.net,user-interface,C#,Asp.net,User Interface,我有一个GridView,下面有三个按钮。我试图找出如何对齐它们,以便第一个按钮的左边缘与GridView的左边缘对齐,第二个按钮位于GridView下方的中心,第三个按钮的右边缘与GridView的右边缘对齐。如果GridView的宽度扩大,我希望按钮与GridView保持对齐。现在,按钮水平排列在一起,向左对齐。 这是我想要的东西的草图 有很多方法可以做到这一点。您可以将按钮放入网格的页脚,或在网格下放置一个与网格宽度相同的大div或table 我会像这样把它们放在页脚模板中:pseudo
有很多方法可以做到这一点。您可以将按钮放入网格的页脚,或在网格下放置一个与网格宽度相同的大div或table 我会像这样把它们放在页脚模板中:pseudo
div width 100%
div 33%
button 1 (align it to left)
div 33%
button 2 (align it to center
div 33%
button 3 (align it to right
如果你知道,你可以使用固定尺寸
编辑:
刚注意到网格下有一个很大的缺口,你可以这样放
div 100%
grid (assuming 100% also)
div (100%)
and div 33% with buttons go here
您可以尝试使用此代码
<FooterTemplate>
<table>
<tr>
<td class=""><asp:Button ID="Btn1" runat="server" Text="Btn1"/>
</td>
<td class=""><asp:Button ID="Btn2" runat="server" Text="Btn2"/>
</td>
<td class=""><asp:Button ID="Btn3" runat="server" Text="Btn3"/>
</td>
</tr>
</table>
</FooterTemplate>
将Gridview和按钮分别放在一张表的不同行中如何 以下是一个具有内联样式的示例:
<table>
<tr>
<td colspan="3" style="width: 100%">
<asp:GridView ID="GridView1" ShowHeader="false">
...
</asp:GridView>
</td>
</tr>
<tr>
<td style="width: 33%; text-align: left">
<asp:Button ID="button1" runat="server" />
</td>
<td style="width: 33%; text-align: center">
<asp:Button ID="button2" runat="server" />
</td>
<td style="width: 33%; text-right">
<asp:Button ID="button3" runat="server" />
</td>
</tr>
</table>
也许您可以尝试在某些样式中添加一些左填充或右填充
<table>
<tr>
<td colspan="3" style="width: 100%">
<asp:GridView ID="GridView1" ShowHeader="false">
...
</asp:GridView>
</td>
</tr>
<tr>
<td style="width: 33%; text-align: left">
<asp:Button ID="button1" runat="server" />
</td>
<td style="width: 33%; text-align: center">
<asp:Button ID="button2" runat="server" />
</td>
<td style="width: 33%; text-right">
<asp:Button ID="button3" runat="server" />
</td>
</tr>
</table>