我后台查询出来的列数是不固定,我想绑定到同一个girdview上行不行?
而且我想样式是统一的,只是增加列数!
最好能给个具体的例子!

解决方案 »

  1.   

    把GridView的AutoGenerateColumns属性设为true,它就会根据查询的结果自动改变列数
      

  2.   

    那就只能自己编写生成table的代码了
      

  3.   

    那么HeaderText这个属性怎么设置,因为不同列式不一样的,在后台实现?
      

  4.   

    把GridView的AutoGenerateColumns属性设为true
      

  5.   

    给GridView套用样式CSS
    将下面的文件保存成mystyle.css文件
    在引用页面的<head></head>间加上<link href="mystyle.css" type="text/css" rel="Stylesheet" />.Grid
    {
    border-right: lightsteelblue 1px solid;
    border-top: lightsteelblue 1px solid;
    border-left: lightsteelblue 1px solid;
    border-bottom: lightsteelblue 1px solid;
    border-collapse: collapse;
    width:auto;

    }.Grid td
    {
    border-right: silver 1px solid;
    padding-right: 5px;
    border-top: silver 1px solid;
    padding-left: 5px;
    padding-bottom: 5px;
    margin: 3px;
    border-left: silver 1px solid;
    padding-top: 5px;
    border-bottom: silver 1px solid;
    font-family: Arial;
    }.GridHeader
    {
    font-size:13px;
    font-weight: bold;
    color: white;
    background-color: #507cd1;
    position:relative ;
        table-layout:fixed;
        top:expression(this.offsetParent.scrollTop);
        /*left:expression(this.offsetParent.scrollLeft);*/
        left:auto;
        z-index: 10;
    }
    .SortGridHeader
    {
    font-size:13px;
    font-weight: bold;
    color:LightGreen;
    background-color: #507cd1;
    position:relative ;
        table-layout:fixed;
        top:expression(this.offsetParent.scrollTop);
        /*left:expression(this.offsetParent.scrollLeft);*/
        left:auto;
        z-index: 10;
    }
    .GridPage
    {
    font-size:13px;
    font-weight: bold;
    color: white;
    background-color: #ffffff;
    position:relative ;
        table-layout:fixed;
        top:expression(this.offsetParent.scrollTop);
        /*left:expression(this.offsetParent.scrollLeft);*/
        left:auto;
        z-index: 10;
    }
    .GridNormalHeader
    {
    font-size:13px;
    font-weight: bold;
    color: white;
    background-color: #507cd1;
    }
    .GridFooter
    {
    font-size:13px;
    font-weight: bold;
    color: white;
    background-color: aliceblue;
    /*position:relative;
    table-layout:fixed;
    bottom:expression(this.offsetParent.scrollBottom);
     bottom:expression(getScrollBottom(this.parentNode.parentNode.parentNode.parentNode));
    left:auto;
    z-index:0;*/
    }