c# - Listview not shown in asp.net -


i have tried implement listview in asp.net. can't output. make mistake don't know. pls me.

my model

enter image description here

aspx

 <asp:listview id="listview1" runat="server">              <itemtemplate>                 <div>                 <asp:table runat="server" >                     <asp:tablerow>                         <asp:tablecell width="40%">                             <asp:label id="label17" runat="server" font-bold="true" font-size="medium"  text='<%#eval("roomtype") %>'></asp:label>                           </asp:tablecell>                         <asp:tablecell width="20%">                              <asp:button id="button1" runat="server" text="search" />                          </asp:tablecell>                     </asp:tablerow>                     <asp:tablerow>                         <asp:tablecell columnspan="2">                             <asp:label id="label18" runat="server" font-bold="true" font-size="medium" text='<%#eval("description") %>'></asp:label>                         </asp:tablecell>                     </asp:tablerow>                 </asp:table>                 </div>              </itemtemplate>         </asp:listview> 

c#

     public class place             {                 public string roomtype { get; set; }                  public string description { get; set; }             }              list<place> items = new list<place>();                         items.add(new place() { roomtype = "roomtype1", description= "roomtype description"});                         items.add(new place() { roomtype = "roomtype2", description = "roomtype description" });                         items.add(new place() { roomtype = "roomtype3", description = "roomtype description" });    listview1.datasource = items; 

while checking break point, recognize items list has items. cant in page.

enter image description here

set datasource listview , try below code

protected void page_load(object sender, eventargs e)         {             list<place> items = new list<place>();             items.add(new place() { roomtype = "roomtype1", description = "roomtype description" });             items.add(new place() { roomtype = "roomtype2", description = "roomtype description" });             items.add(new place() { roomtype = "roomtype3", description = "roomtype description" });             this.listview1.datasource = items;             this.listview1.databind();         } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -