Can you help me with ListView, ItemTemplate, Label controls way of delivering the results. Here's my code:
<asp:ListView ID="lstViewResultsUpdate" runat="server" DataItem="Object">
<LayoutTemplate>
<h3>Listing</h3>
<blockquote>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</blockquote>
</LayoutTemplate>
<ItemSeparatorTemplate>
<hr />
</ItemSeparatorTemplate>
<ItemTemplate>
Label2 - <asp:Label runat="server" ID="Label2" Text='<%# GetAllValues(((Dictionary<string,List<string>>)Container.DataItem)["Test1"]) %>' />
<br/><br/><hr>
Label3 - <asp:Label runat="server" ID="Label3" Text='<%# GetAllValues(((Dictionary<string,List<string>>)Container.DataItem)["Test2"]) %>' />
</ItemTemplate>
</asp:ListView>
The codebedind is:
public string GetAllValues(object lst)
{
List<string> lstOfStr = (List<string>)lst;
//lstOfStr.Clear();
string allValues = "";
foreach (string str in lstOfStr)
allValues += "," + str;
return allValues;
}
...and the result is:
Label2 - Label2item1, Label2item2, Label2item3, etc.
<hr>
Label3 - Label3item1, Label3item2, Label3item3, etc.
How to make the resul开发者_如何学Pythont:
Label2 - Label2item1
<hr>
Label3 - Label3item1
Label2 - Label2item2
<hr>
Label3 - Label3item2
Label2 - Label2item3
<hr>
Label3 - Label3item4
I have difficulties with codebehind part:
public static IEnumerable<Article> GetArticles()
{ // data access code not shown }
How to convert the code form my first post to code in this public static method?
Something like this should work. Environment.Newline is the way I'd go.
allValues += Environment.NewLine + "," + str;
精彩评论