gridview小知识点_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > gridview小知识点

gridview小知识点

 2011/1/9 9:19:09  垂直的微笑  http://shenling258-hotmail-com.javaeye.com  我要评论(0)
  • 摘要:gridview表头冻结<styletype="text/css">.DataGridFixedHeader{LEFT:0px;POSITION:relative;TOP:expression(this.offsetParent.scrollTop-2);}</style><tablecellpadding="0"cellspacing="10"width="100%"border="0"><style>div.contenttable
  • 标签:view
gridview表头冻结
<style type="text/css">
            .DataGridFixedHeader
{
LEFT: 0px; POSITION: relative; TOP: expression(this.offsetParent.scrollTop-2);
             }
        </style>

<table cellpadding="0" cellspacing="10" width="100%" border="0" >
<style>
div.content table.gridView th {
text-align:center;
vertical-align: middle;
border: none;
padding: 5px 6px;
}
div#gridviewarea
{
" border-left: solid 1px #A5ABBD;"
" border-bottom: solid 1px #A5ABBD;"
" border-right: solid 1px #A5ABBD;"
" border-top: solid 1px #A5ABBD;"
}
</style>
<tr>
<td>
<div id="Div1" style="position:relative;width:100%;height:400px;overflow-x:auto;overflow-y:auto">
            <asp:GridView ID="grvCompanyList0" runat="server" AutoGenerateColumns="False"
                GridLines="None" OnSorting="CompanyListSorting" OnRowCommand="CompanyListRowCommand"
                CssClass="gridView" Width="150%" CellPadding="0" CellSpacing="0" BorderWidth="0">
                <RowStyle CssClass="gridBodyRow" />
                <HeaderStyle CssClass="DataGridFixedHeader" />
                <AlternatingRowStyle CssClass="gridAlternatingRow" />
                <Columns>

表头追加合并行
<asp:GridView ID="GridView1" runat="server"    。。。。。。。。 onprerender="GridView1_PreRender" 。。。。。。。。。

protected void GridView1_PreRender(object sender, EventArgs e) 在加载 Control 对象之后、呈现之前发生。 protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
        { 在页面有多次多种刷新的情况下有异常,         {
            //セルを追加(タイトルの数分) 现将这段后台追加合并的表头的写在RowCreated事件中 if (e.Row.RowType == DataControlRowType.Header)
            TableHeaderCell cell = new TableHeaderCell();             {
…….
            //ヘッダー行を宣言 …….
            GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.Header, DataControlRowState.Alternate);

            //colspan をプロパティ設定
            cell.ColumnSpan = 4;
            //ヘッダーテキストを設定
            cell.Text = "会社";
            cell.Attributes.Add("HeaderStyle-CssClass", "gridHeaderRow");
            cell.Attributes.Add("style", "TEXT-ALIGN: Center");
            //行にセルを追加
            row.Cells.Add(cell);

            //GridView に結合する
            GridView1.Controls[0].Controls.AddAt(0, row);

            GridView1.Rows[0].Cells[0].Width = 400;
            GridView1.Rows[0].Cells[1].Width = 150;
            GridView1.Rows[0].Cells[2].Width = 400;
            GridView1.Rows[0].Cells[3].Width = 150;

        }







<% if (isDataExist)
{ %>
<table cellpadding="0" cellspacing="10" width="100%" border="0" >
<style>
div.content table.gridView th {
text-align:center;
vertical-align: middle;
border: none;
padding: 5px 6px;
}

div#gridviewarea
{
" border-left: solid 1px #A5ABBD;"
" border-bottom: solid 1px #A5ABBD;"
" border-right: solid 1px #A5ABBD;"
" border-top: solid 1px #A5ABBD;"
}
</style>

<tr>
<td>
……


gridciew内自动换行
e.Row.Cells[2].Style.Add("word-break", "break-all")

//正常换行
??????? GridView1.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");
??????? //下面这行是自动换行
??????? GridView1.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");








grid的单元内容右对齐
.td_right
            {
                text-align:right !important;
            }

<asp:TemplateField HeaderText="全て" HeaderStyle-Width="12%" ItemStyle-CssClass="td_right">
                                    <ItemTemplate>










grid中某一情况下设定行背景色
if (e.Row.RowType == DataControlRowType.DataRow)
            {
if (……)
……
                e.Row.CssClass = "gridviewreverserow";               
            }


base_styles.css
tr.gridviewreverserow {
        background:#660066 ;
}


发表评论
用户名: 匿名