safari浏览器下开发,现页面上有一个gridview控件:
<asp:GridView ID="gvVitalData" runat="server" AutoGenerateColumns="False"                                    ShowHeader="False" BorderStyle="None" BorderWidth="0px" CellPadding="0">
                                    <AlternatingRowStyle BackColor="White" />
                                    <Columns>
                                        <asp:BoundField DataField="A">
                                            <ItemStyle Width="103px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="B">
                                            <ItemStyle Width="103px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="C">
                                            <ItemStyle Width="103px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="D">
                                            <ItemStyle Width="103px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="E">
                                            <ItemStyle Width="103px" />
                                        </asp:BoundField>
                                    </Columns>
                                    <RowStyle Height="27px"></RowStyle>
                                </asp:GridView>
显示效果为前两行数据居中显示,其他数据居右显示。此效果如何实现,望各位大侠指教 ...

解决方案 »

  1.   

    GridView1.Rows[0].Style = "text-align:center";
    GridView1.Rows[1].Style = "text-align:center";
      

  2.   

    在绑定事件里判断行的位置,然后e.Row.Attributes.Add("style","text-align:right")
      

  3.   


    <Chsoft:SmartGridView ID="gv基础_城市" runat="server" Width="100%" IsShowSingleSelectColumn="true"
                        BorderStyle="None" AllowPaging="true" IsShowFooterToolbar="True" IsShowHeaderToolbar="true"
                        IsSinglePageDataMode="False" IsDoubleClickSelectOneLine="true" PageSize="15"
                        OnRowDataBound="gv基础_城市_RowDataBound" IsTriggerSelect="false" IsHideCheckBoxColumn="false"
                        SingleSelectColumnValueFiled="城市ID" IsAutoSetHorizontalAlign="false"
    OnRowCommand="gv基础_城市_RowCommand">
                        <Columns>
    <asp:TemplateField HeaderText="城市名称">
                                <ItemStyle HorizontalAlign="Left" Width="150px" />
                                <ItemTemplate>
                                    <asp:LinkButton ID="btn城市名称" runat="server" Text='<%#Eval("城市名称")%>' CommandArgument='<%#Eval("城市ID")%>'
                                        CommandName="ViewData"></asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
    <asp:TemplateField HeaderText="所属省份">
                                <ItemStyle HorizontalAlign="Left" Width="150" />
                                <ItemTemplate>
                                    <%#Eval("省名称")%>
                                </ItemTemplate>
                            </asp:TemplateField>
    <asp:TemplateField HeaderText="排序号">
                                <ItemStyle HorizontalAlign="Right" Width="30"/>
                                <ItemTemplate>
                                    <%#Eval("排序号")%>
                                </ItemTemplate>
                            </asp:TemplateField>
    <asp:TemplateField HeaderText="状态">
                                <ItemStyle HorizontalAlign="Center" Width="60px" />
                                <ItemTemplate>
                                    <asp:Label ID="lbl状态" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <HeaderStyle BackColor="White" Font-Bold="True" Font-Size="9pt" VerticalAlign="Middle"
                            Wrap="True" />
                        <PagerStyle VerticalAlign="Top" />
                        <AlternatingRowStyle VerticalAlign="Top" />
                    </Chsoft:SmartGridView>
      

  4.   

    GridView1_RowDataBound在这个事件里
    GridView1.Rows[0].Style = "text-align:center";
    GridView1.Rows[1].Style = "text-align:center"; protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        { 
           GridView1.Rows[0].Style = "text-align:center";
            GridView1.Rows[1].Style = "text-align:center";
    //颜色设置
        }