asp.net 2.0控件一些有可能是bug的小问题:
(1)不允许重新绑定的情况下,编码设置ShowHeader,ShowFooter属性:
页面上放一个 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" PageSize="5" ShowFooter="True" AllowSorting="True"> </asp:GridView>
不使用DataSource控件,而是用编程方式对其进行绑定; 有两个按钮,一个是将ShowHeader,ShowFooter属性设置为True,另一个则是设置为False。执行,点击ButtonF,一次没反应,点两次,Header和Footer都不见了;再点击ButtonT,Header和Footer可能就不会再显示了。
用DataSource控件进行绑定就不会有这个问题,但是,这会自动从数据库读取数据并重新绑定。

(2)设置GridView的HeaderStyle.Font.Bold属性为False,没有效果:
这只是个小问题而已,但是明显是不对的。GridView控件的列头,会生成<th></th>标签,但是如果用户设置了该属性为False,应该要有所体现,然而没有,我们不得不通过下面的代码才能让列头不用粗体显示:
1 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
2 {
    {
3 if (e.Row.RowType == DataControlRowType.Header)
        if (e.Row.RowType == DataControlRowType.Header)
4 {
        {
5 foreach(TableCell cell in e.Row.Cells)
            foreach(TableCell cell in e.Row.Cells)
6 cell.Attributes.Add("style","FONT-WEIGHT:normal");
                cell.Attributes.Add("style","FONT-WEIGHT:normal");
7 }
        }
8 }
    }
9
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)2
 {
    {3
 if (e.Row.RowType == DataControlRowType.Header)
        if (e.Row.RowType == DataControlRowType.Header)4
 {
        {5
 foreach(TableCell cell in e.Row.Cells)
            foreach(TableCell cell in e.Row.Cells)6
 cell.Attributes.Add("style","FONT-WEIGHT:normal");
                cell.Attributes.Add("style","FONT-WEIGHT:normal");7
 }
        }8
 }
    }9

(3)在asp.net 2.0中使用DataGrid控件,在下面的特定情况下Pager的样式会有变化:
 <asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True" PageSize="2" AutoGenerateColumns="False">
<asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True" PageSize="2" AutoGenerateColumns="False"> <Columns>
        <Columns> <asp:BoundColumn DataField="id" HeaderText="ID"></asp:BoundColumn>
            <asp:BoundColumn DataField="id" HeaderText="ID"></asp:BoundColumn> <asp:BoundColumn DataField="name" HeaderText="NAME"></asp:BoundColumn>
            <asp:BoundColumn DataField="name" HeaderText="NAME"></asp:BoundColumn> <asp:BoundColumn DataField="sex" HeaderText="SEX"></asp:BoundColumn>
            <asp:BoundColumn DataField="sex" HeaderText="SEX"></asp:BoundColumn> <asp:TemplateColumn HeaderText="选择"><ItemTemplate>
            <asp:TemplateColumn HeaderText="选择"><ItemTemplate> <asp:LinkButton id="LinkButton1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Name") %>' CommandName="Select"></asp:LinkButton>
<asp:LinkButton id="LinkButton1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Name") %>' CommandName="Select"></asp:LinkButton> </ItemTemplate></asp:TemplateColumn>
</ItemTemplate></asp:TemplateColumn> </Columns>
        </Columns> <PagerStyle HorizontalAlign="Center" />
        <PagerStyle HorizontalAlign="Center" /> </asp:DataGrid>
    </asp:DataGrid> 
                     
                    
                 
                    
                 

 
         
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号