gridview的数据显示格式问题,请帮忙!
一般的显示方法是:
字段1 字段2 字段3
A A1 A2
B B1 B34
C1 Ce c3
我现在想显示成:
字段1 字段2
字段3
A A1
A2
B B1
B34
C1 Ce
c3
代码如下:怎么改请各位帮忙
<asp:GridView ID= "GridView1 " runat= "server " AutoGenerateColumns= "False " >
<columns>
<asp:HyperLinkField DataNavigateUrlFields= "id "DataTextField= "字段1 " >
</asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields= "id "DataTextField= "字段2 " >
</asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields= "id "DataTextField= "字段3 " >
</asp:HyperLinkField>
</columns>
</asp:GridView>
------解决方案--------------------用一个模板字段
<columns>
...
<asp:templatefield>
<itemtemplate>
<asp:HyperLink runat= "server " NavigateUrl= ' <%# Eval( "ID ") %> ' Text= ' <%# Eval( "字段2 ") %> '/>
<br/>
<asp:HyperLink runat= "server " NavigateUrl= ' <%# Eval( "ID ") %> ' Text= ' <%# Eval( "字段3 ") %> '/>
</itemtemplate>
</asp:templatefield>
</columns>
参考
http://authors.aspalliance.com/aspxtreme/webforms/controls/addingtemplatefieldstogridview.aspx
------解决方案--------------------使用repeater使用比较容易实现
但是gridview也一样 基本思路表头合并
------解决方案--------------------看过了,是正解~!
saucer(思归) 都三颗钻石了
分给我吧????
------解决方案--------------------模板 来晚了
<itemtemplate>
<asp:HyperLink runat= "server " NavigateUrl= ' <%# Eval( "ID ") %> ' Text= ' <%# Eval( "字段2 ") %> '/>
<br/>
<asp:HyperLink runat= "server " NavigateUrl= ' <%# Eval( "ID ") %> ' Text= ' <%# Eval( "字段3 ") %> '/>
</itemtemplate>
------解决方案-------------------- <asp:templatefield>
<itemtemplate>
<asp:HyperLink runat= "server " NavigateUrl= ' <%# Eval( "ID ") %> ' Text= ' <%# Eval( "字段2 ") %> '/>
<br/>
<asp:HyperLink runat= "server " NavigateUrl= ' <%# Eval( "ID ") %> ' Text= ' <%# Eval( "字段3 ") %> '/>
</itemtemplate>