ASP.NET:如何在DataBind中跳过Repeater中的值 [英] ASP.NET: How to skip a value in Repeater when DataBind

查看:41
本文介绍了ASP.NET:如何在DataBind中跳过Repeater中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我的.aspx代码如下:工作正常:

< asp:Repeater ID = rptMenuAdmin" RUNAT = QUOT;服务器"> 
< HeaderTemplate>
< table>
< / HeaderTemplate>
< ItemTemplate>
< tr>
< td id =" navItemBullet">< img scr =" navBullet.gif">< / td>
< td>< a href ="<%#Eval(" mnuItemUrl")。ToString()%>" id =" navItemLink"><%#Eval(" mnuItemName")%>< / a>< / td>
< tr>
< / ItemTemplate>
< FooterTemplate>
< / table>
< / FooterTemplate>
< / asp:Repeater>

这将从SQL数据库创建我的菜单项,其中项目是项目符号(第一个td)及其链接(第二个td) )。


我想跳过这两个< td> ...< / td>当数据库中的mnuItemName值为"< hr>"时并写:

< td colspan =" 2"><%#Eval(" mnuItemName")%>< / td> 

在  .aspx页面 我尝试使用OnItemDataBound。


在.cs中这应该拦截"< hr> "但
我不知道
如何。



欢迎任何想法...


感谢您的帮助!







NeAndy

解决方案

Hello There,


您可以在  ItemDataBound


干杯 


Dinesh


Hello,

My .aspx code is bellow and works fine :

<asp:Repeater ID=rptMenuAdmin" runat="server">
    <HeaderTemplate>
        <table>
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td id="navItemBullet"><img scr="navBullet.gif"></td>
            <td><a href="<%# Eval("mnuItemUrl").ToString() %>" id="navItemLink"><%# Eval("mnuItemName") %></a></td>
        <tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>

This create my menu items from SQL DataBase, where a item is an bullet (first td) and its link (second td).

I want skip these two <td>...</td> when mnuItemName value in the database is "<hr>" and write:

<td colspan="2"><%# Eval("mnuItemName") %></td>

In .aspx page I tried with OnItemDataBound.

In .cs this should to intercept the "<hr>" but I do not know how.

Any idea is welcome...

Thanks for your help !


NeAndy

解决方案

Hello There,

You can do it in ItemDataBound

Cheers 

Dinesh


这篇关于ASP.NET:如何在DataBind中跳过Repeater中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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