简体   繁体   English

网格视图格式Asp.net我的代码已附加

[英]Grid View Formatting Asp.net my code Attached

as i wanna format my grid view as it is only showing data like this, 因为我要格式化网格视图,因为它只显示这样的数据,

john
Adam
Morkel
Kalis
.
.
.

.

i wanna show them in this way , 我想以这种方式向他们展示,

john    Kalis   .
                . 
Adam    Chris   .
         .      .
morkel   .      .

my code after attaching data sorce, 我的代码附加数据源后,

GridView1.DataSource = dt;
GridView1.DataBind();

hopes for your Suggestions thanks in Advance 希望您的建议在此先感谢

You're better off using a DataList control. 最好使用DataList控件。

for your multi row/multi column need, take a look at " Step 3: Displaying Data in a Multi-Column, Multi-Row Table " at http://www.asp.net/web-forms/tutorials/data-access/displaying-data-with-the-datalist-and-repeater/showing-multiple-records-per-row-with-the-datalist-control-vb 为满足您的多行/多列需求,请访问http://www.asp.net/web-forms/tutorials/data-access中的步骤3:在多列多行表中显示数据/与数据列表和中继器一起显示数据/与数据列表控制vb每行显示多个记录

I think you have to use DataList instead of gridview 我认为您必须使用DataList而不是gridview

check these examples 检查这些例子

http://www.asp.net/web-forms/tutorials/data-access/displaying-data-with-the-datalist-and-repeater/displaying-data-with-the-datalist-and-repeater-controls-vb http://www.asp.net/web-forms/tutorials/data-access/displaying-data-with-the-datalist-and-repeater/displaying-data-with-the-datalist-and-repeater-controls- vb

http://www.packtpub.com/article/working-with-asp-dot-net-datalist-control http://www.packtpub.com/article/working-with-asp-dot-net-datalist-control

Edit: 编辑:

.aspx 的.aspx

  <ItemTemplate>
    <ul>
       <li> <%# Container.DataItem %></li>
    </ul>
  </ItemTemplate>

</asp:DataList>

.cs .cs

 List<string> ss = new List<string>();
    ss.Add("john");
    ss.Add("Adam");
    ss.Add("Morkel");
    ss.Add("Kalis");
    ss.Add("Chris");
    DataList1.DataSource=ss;
    DataList1.DataBind();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM