<asp:GridView ID="GridView2" runat="server" Width="600px" AutoGenerateColumns="False"> <Columns> <asp:BoundField DataField="CS" HeaderText="选项" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="70%" ItemStyle-HorizontalAlign="Left" /><%--HeaderStyle-Width="250px"--%> <asp:BoundField DataField="CS_PERCENT" ItemStyle-HorizontalAlign="Center" HeaderText="占百分比" ItemStyle-Width="15%" HeaderStyle-HorizontalAlign="Center" /><%--HeaderStyle-Width="100px"--%> <asp:BoundField DataField="CS_COUNT" ItemStyle-HorizontalAlign="Center" HeaderText="投票人数" ItemStyle-Width="15%" HeaderStyle-HorizontalAlign="Center" /><%--HeaderStyle-Width="100px"--%> </Columns>
</asp:GridView>
HeaderStyle-HorizontalAlign="Center"是控制列标题的位置
ItemStyle-HorizontalAlign="Center" 是控制列项的位置
ItemStyle-Width="15%" 设置列项的宽度
<tr> <td colspan="2"> <asp:Label ID="lbl_Order" runat="server" Text='<%# Eval("VoteOrder") %>'></asp:Label> <asp:Label ID="LVetoco" runat="server" Text='<%# Eval("VOTECO")%>'></asp:Label> </td> </tr> <tr> <td valign="bottom"> <asp:Button ID="btn_Detail" runat="server" Text="其他建议详情" Visible="false" OnClientClick='<%# "WordDetail(" + Eval("PersonWord_ID") + ")" %>' /> </td> </tr>
<td colspan="2">设置为两个单元格的长度,这样样式更好看
<td valign="bottom">指的是把这列的值放在单元格的下角位置