看看GridView的布局代码

看看GridView的布局代码:

 
    <asp:GridView ID="gvStudent" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                                    EnableModelValidation="True" Font-Size="12pt" OnPageIndexChanging="gvStudent_PageIndexChanging"
                                    Width="100%" DataKeyNames="UserID" 
                                    OnSelectedIndexChanging="gvStudent_SelectedIndexChanging" Font-Names="宋体">
                                    <SelectedRowStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedRowStyle>
 
 
                                    <AlternatingRowStyle Font-Size="9pt" HorizontalAlign="Center" BackColor="#E8F4FF"></AlternatingRowStyle>
 
 
                                    <RowStyle Font-Size="9pt" HorizontalAlign="Center" ForeColor="#003399" BackColor="White"> </RowStyle>
 
                                    <HeaderStyle HorizontalAlign="Center" ForeColor="White" VerticalAlign="Middle" BackColor="#337FB2"> </HeaderStyle>
 
 
                                    <FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>
                                    <Columns>
                                        <asp:BoundField DataField="UserID" HeaderText="学号" ReadOnly="True" />
                                        <asp:BoundField DataField="Pwd" HeaderText="密码" />
                                        <asp:BoundField DataField="UserName" HeaderText="学生姓名" />
                                        <asp:BoundField DataField="LoginTimes" HeaderText="考生登录次数" />
                                        <asp:TemplateField HeaderText="试卷提交状态">
                                            <ItemTemplate>
                                                <asp:Label ID="Labeltatus" runat="server" Text='<%# Eval("Examstatus").ToString() == "1"?"已提交":"未提交"%>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="RemainTime" HeaderText="考生剩余时间" />
                                        <asp:TemplateField HeaderText="选 择" ShowHeader="False">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Select"
                                                    Text="选择"></asp:LinkButton>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
 
 
重点关注红色部分的代码:这是对GridView样式设计及使用其关键作用的语句:
 
    分析:SelectedRowStyle ========》》使用 SelectedRowStyle 属性控制 GridView 控件中选中行的外观。
 
        AlternatingRowStyle========》》使用 AlternatingRowStyle 属性控制 GridView 控件中交替数据行的外观。
 
        RowStyle===============》》使用 RowStyle 属性控制 GridView 控件中数据行的外观。
 
        HeaderStyle============》》使用 HeaderStyle 属性控制 GridView 控件中标题行的外观。
 
        FooterStyle============》》使用 FooterStyle 属性控制 GridView 控件中脚注行的外观。
 
 
 
 
 
posted @ 2012-06-28 22:26  AllenLYU  阅读(1255)  评论(0编辑  收藏  举报
levels of contents