ASP.NET (C#) - ListView -


in past, worked on listviews (.net 2.0) using custom template field trying achieve here following

feedly example

i working on .net 4.6

so list shows items above , on mouse-hover few options show shown in following screenshot

feedly example

i have trigger option different things -

how can in asp.net, may please have code references.

cheers

p.s. rough example of how creating list item template (as requested)

<asp:listview id="listview1" runat="server" datasourceid="sqldatasource1">            <alternatingitemtemplate>             <table >                     <tr>                         <td ><asp:image  id="image1" imageurl='<%# bind("url") %>' runat="server" width="98px" /> </td>                         <td><h2><asp:label id="_label" runat="server" text ='<%# bind("title") %>'></asp:label></h2><asp:label id="label1" runat="server" text ='<%# bind("description") %>'></asp:label></td>                     </tr>                   </table>             </alternatingitemtemplate>              <emptydatatemplate>                 no data returned.             </emptydatatemplate>                <itemseparatortemplate>                 <br />             </itemseparatortemplate>              <itemtemplate>                 <table >                     <tr>                         <td ><asp:image  id="image1" imageurl='<%# bind("url") %>' runat="server"  width="98px" /> </td>                         <td><h2><asp:label id="_label" runat="server" text ='<%# bind("title") %>'></asp:label></h2><asp:label id="label1" runat="server" text ='<%# bind("description") %>'></asp:label></td>                     </tr>                   </table>             </itemtemplate>             <layouttemplate>                                 <ul id="itemplaceholdercontainer" runat="server" style="">                     <li runat="server" id="itemplaceholder" />                 </ul>                 <div style="">                 </div>             </layouttemplate>          </asp:listview> 

i can add html formatting template e,g can add asp:button etc don't know how trigger perform tasks.

one easy way achieve requirement keep buttons there invisible , show them when parent container hovered. following quick sample

aspx

<asp:listview id="listview1" runat="server">     <itemtemplate>         <tr class="row-data">             <td>                 <asp:label id="namelabel" runat="server" text='<%# eval("name") %>' />             </td>             <td>                 <asp:label id="positionlabel" runat="server" text='<%# eval("position") %>' />             </td>             <td>                 <div class="btn-area">                     <asp:button runat="server" text="button1" />                     <asp:button runat="server" text="button2" />                 </div>             </td>         </tr>     </itemtemplate>     <layouttemplate>         <table id="itemplaceholdercontainer" runat="server" border="0" style="">             <tr runat="server" style="">                 <th runat="server">                     name                 </th>                 <th runat="server">                     position                 </th>                 <th>                 </th>             </tr>             <tr id="itemplaceholder" runat="server">             </tr>         </table>     </layouttemplate> </asp:listview> 

css

.btn-area {     display: none; }  .row-data:hover .btn-area {     display: block; } 

code-behind

protected void page_load(object sender, eventargs e) {     listview1.datasource = new list<dynamic>() {         new { name = "andy", position = "pg"},         new { name = "bill", position = "sd"},         new { name = "caroline", position = "manager"}     };     listview1.databind(); } 

update
listview itemcommand can capture postback button pressed , commandname makes able recognize button fired it.

<asp:button runat="server" text="button1" commandname="c1" /> <asp:button runat="server" text="button2"  commandname="c2" /> 

code-behind

protected void listview1_itemcommand(object sender, listviewcommandeventargs e) {     if (e.commandname == "c1")     {         // when button1 pressed     }     else if (e.commandname == "c1")     {         // when button2 pressed     } } 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -