ListView Asp.Net control - Assigning strings to Listview columns -


listview web control question:

i developed report service web application using asp.net 3.5 , reportingservice2010.asmx. retrieved itemhistorysnapshots following code:

itemhistorysnapshot[] itemsnapshots = null; itemsnapshots = rs.listitemhistory(strchildnode);  foreach(itemhistorysnapshot snapshot in itemsnapshots) {     listview.add (snapshot.historyid.tostring());     listview.add (snapshot.size.tostring());     listview.add(snapshot.datetime.tostring()); } 

i want create listview 3 columns historyid, size, datetime , want assign string values in foreach loop.

please let me know how assign string values listview. want know source control code listview also. thank much.

you can use repeater , bind data it, this:

code behind:

itemhistorysnapshot[] itemsnapshots = null; itemsnapshots = rs.listitemhistory(strchildnode);  rpt.datasource = itemsnapshots.select(s => new  {   historyid = s.historyid.tostring(),   size = s.size.tostring(),   datetime = s.datetime.tostring(), }); rpt.databind(); 

aspx page:

<asp:repeater id="rpt" runat="server">    <headertemplate>     <table border="1" width="100%">         <tr>           <th>historyid</th>           <th>size</th>           <th>datetime</th>       </tr>   </headertemplate>    <itemtemplate>     <tr>       <td><%# eval("historyid") %></td>       <td><%# eval("size") %></td>       <td><%# eval("datetime") %></td>     </tr>   </itemtemplate>    <footertemplate>     </table>   </footertemplate>  </asp:repeater> 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -