如何动态地将项目添加到listview? [英] How do I add item to listview dynamically?

查看:93
本文介绍了如何动态地将项目添加到listview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

我有asp.net listview,我有这样的项目:



< asp:ListView ID =   ListView1 ... ItemType =   Base.Models.Doc runat =   server >  
...
< ItemTemplate >
< tr>
< td><%#Item.F1 %> < / < span class =code-leadattribute> td >
< td><%#Item.F2 %> < / td >
< td><%#Item.F3 %> < / td >
< td>< %#Item.F4 %> < / td >
< td><%#Item.Tab %> < / td >
< td><%#Item.Bom %> < / td >
< td id = 这个><%#Item.Status %> < / td >
< / ItemTemplate >





我想输出最后一个td id =THIS只有Item.Status存在(如果我的数据库中的列)名称为状态存在。我该怎么做?在codebehind或html中。



我尝试过:



尝试 - 捕获,尝试在代码隐藏中使其可见= false。尝试动态添加此td。

解决方案

检查项目后您可以使用的下述逻辑是否存在于表格中。

检查项目 - 你可以通过jquery ajax调用来完成。



逻辑在下面的URL中解释。点击添加按钮时添加。在你的情况下它将在db调用之后满足条件。





[ ^ ]



如果有任何疑问或您认为我们可以修改解决方案,请告诉我。


 


( #header ul)。append('< li>< a href =/ user / messages>< span class =tab>消息中心< / s平移>< / A>< /立GT;);


Hi All.
I have asp.net listview and i have items in this:

     <asp:ListView ID="ListView1" ... ItemType="Base.Models.Doc" runat="server"  >
   ...
<ItemTemplate >
            <tr>
<td><%# Item.F1 %></td>
         <td><%# Item.F2 %></td>
         <td><%# Item.F3 %></td>
        <td><%# Item.F4  %></td>
         <td><%# Item.Tab %></td>
         <td><%# Item.Bom %></td>
   <td id="THIS" ><%#  Item.Status %></td>
     </ItemTemplate>



I want to output last "td id="THIS"" only if Item.Status exist (if column in my database with name "Status" exist . How can i make this? In codebehind or in html .

What I have tried:

Try - catch , try to make it visible=false in codebehind . Try to add this td dynamically .

解决方案

The below mentioned logic you can use after checking your item is present in the table or not.
checking of item- you can do via jquery ajax call.

Logic is explained in the below URL.They are adding when add button is clicked.In your case it will be when the condition satisfies after a db call.


[^]

Do let me know in case any queries or if you think we can modify the solution.



("#header ul").append('<li><a href="/user/messages"><span class="tab">Message Center</span></a></li>');


这篇关于如何动态地将项目添加到listview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆