如何使用GridView每行创建动态表4列?

时间:2015-06-05 02:57:55

标签: c# css asp.net twitter-bootstrap gridview

您好我是c#和bootstrap的新手,我想使用gridview对下面的图片进行样式设置并使其响应,我不知道如何实现它。

aspx代码:

<div class="table-responsive"> 
    <asp:GridView runat="Server" id="data" CssClass="table table-hover table-bordered"/>
</div>

css代码:

.table-responsive{
    margin: 20px;
}

enter image description here

但是我的表的输出看起来像这样  enter image description here

2 个答案:

答案 0 :(得分:1)

您无法实现GridView的结构。你真正需要的是FormView。在FormView ItemTemplate内,用您所需的标记定义table

MSDN网址:Using the FormView's Templates

答案 1 :(得分:0)

对c#不太了解,但使用bootstrap,您可以使用类rowcol-sm-3col-md-3col-lg-3来表示不同的视图。

<div class="table-responsive"> 
    <div class="row">
        <div class="col-sm-3 col-md-3">section1</div>
        <div class="col-sm-3 col-md-3">section2</div>
        <div class="col-sm-3 col-md-3">section3</div>
        <div class="col-sm-3 col-md-3">section4</div>
    </div>
</div>

提供更多帮助http://getbootstrap.com/css/#grid