【发布时间】:2014-06-16 23:45:15
【问题描述】:
您好,我正在尝试在 2 列中显示数据..例如
col col
A E
B F
C G
D H
我可以显示单列,但无法显示 2 列,当我在 gridview 中添加新字段以显示列时,它会显示同一列。喜欢
col col
A A
B B
C C
D D
我想连续显示数据。请建议我一个解决方案。 谢谢
<asp:GridView
] ID="GridViewProducts"
DataKeyNames="pkProductId,RetailPrice"
runat="server"
OnSelectedIndexChanged="getSelectedRowToCard"
AutoGenerateColumns="false"
AllowPaging="True"
PageSize="4"
OnPageIndexChanging="OnNewPage"
BorderWidth="0px"
BorderColor="White" Width="341px">
<Columns>
<asp:CommandField ShowSelectButton="True" SelectText="ADD To Card"/>
<asp:TemplateField>
<ItemTemplate>
<br />
Description:
<asp:HyperLink ID="SelectProduct" NavigateUrl="~/Home.aspx"
runat="server"><%#Eval("Description").ToString()%>
</asp:HyperLink>
<br />
TypeDescription: <%#Eval("TypeDescription").ToString()%>
<br />
<span style="color: #FF3300">RetailPrice:$</span>
<%#Eval("RetailPrice").ToString()%>
<br />
Weight: <%#Eval("Weight").ToString()%>
<%--<asp:Button ID=btn runat="server" Text="Add to Cart"
OnCommand="getSelectedRowToCard"/>--%>
<br />
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField />
<asp:CommandField SelectText="ADD To Card" ShowSelectButton="True" />
<asp:TemplateField>
<ItemTemplate>
<br />
Description:
<asp:HyperLink ID="SelectProduct" runat="server"
NavigateUrl="~/Home.aspx"><%#Eval("Description").ToString()%>
</asp:HyperLink>
<br />
TypeDescription: <%#Eval("TypeDescription").ToString()%>
<br />
<span style="color: #FF3300">RetailPrice:$</span>
<%#Eval("RetailPrice").ToString()%>
<br />
Weight: <%#Eval("Weight").ToString()%>
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField />
</Columns>
</asp:GridView>
【问题讨论】:
-
请发布您的代码。
-
请向我们展示您的代码。
-
投反对票:没有看到你的代码怎么能告诉你有什么问题?
-
我建议你使用 Datalist 而不是 Grid 视图,你可以在 datalist 中轻松设置列。
-
我已经添加了aspx代码...