Repeater Problem

A

Ahmd

I have a Repeater to which a sitemap is bound, i want to remove or
hide any node while form load

<asp:Repeater runat="server" ID="menu"
DataSourceID="SiteMapDataSource1" EnableViewState="False">
<ItemTemplate>
<li>
<asp:HyperLink ID="HyperLink1"
runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></
asp:HyperLink>

<asp:Repeater ID="Repeater1"
runat="server" DataSource='<%# CType(Container.DataItem,
SiteMapNode).ChildNodes %>'>
<HeaderTemplate>
<ul>
</HeaderTemplate>

<ItemTemplate>
<li>
<asp:HyperLink
ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("Url") %>'><%#
Eval("Title") %></asp:HyperLink>
</li>
</ItemTemplate>

<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
</asp:Repeater>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
ShowStartingNode="false" />

I have the site map attached to the repeater.

site map
<siteMapNode url="~/Default.aspx" title="Home" description="">
<siteMapNode title="IRF / IDF ">
<siteMapNode url="~/IRF.aspx" title="IR Form" />
<siteMapNode url="~/IDF.aspx" title="ID Form" />
</siteMapNode>
<siteMapNode title="Membership">
<siteMapNode url="~/Membership/CreatingUserAccounts.aspx"
title="Create User" />
<siteMapNode url="~/Membership/PagePermission.aspx"
title="Authorisation" />
</siteMapNode>
<siteMapNode title="MIS">
<siteMapNode url="~/MIS.aspx" title="MIS" />
<siteMapNode url="~/Department.aspx" title="Department" />
<siteMapNode url="~/IRFReport.aspx" title="Test" />
</siteMapNode>
</siteMapNode>
</siteMap>


Want to hide or remove one or 2 node on page Load
pls help
 
E

Eliyahu Goldin

To change the number of shown items, it is usually better to operate on the
datasource than on the bound control.

If you insist on doing that on the repeater, handle the ItemDataBound event,
use FindControl method to locate the hyperlink inside the item and set the
hyperlink's Visible property to false.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
A

Ahmd

To change the number of shown items, it is usually better to operate on the
datasource than on the bound control.

If you insist on doing that on the repeater, handle the ItemDataBound event,
use FindControl method to locate the hyperlink inside the item and set the
hyperlink's Visible property to false.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net


I have a Repeater to which a sitemap is bound, i want to remove or
hide any node while form load
<asp:Repeater runat="server" ID="menu"
DataSourceID="SiteMapDataSource1" EnableViewState="False">
<ItemTemplate>
<li>
<asp:HyperLink ID="HyperLink1"
runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></
asp:HyperLink>
<asp:Repeater ID="Repeater1"
runat="server" DataSource='<%# CType(Container.DataItem,
SiteMapNode).ChildNodes %>'>
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink
ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("Url") %>'><%#
Eval("Title") %></asp:HyperLink>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
</asp:Repeater>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
ShowStartingNode="false" />
I have the site map attached to the repeater.
site map
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"
<siteMapNode url="~/Default.aspx" title="Home" description="">
<siteMapNode title="IRF / IDF ">
<siteMapNode url="~/IRF.aspx" title="IR Form" />
<siteMapNode url="~/IDF.aspx" title="ID Form" />
</siteMapNode>
<siteMapNode title="Membership">
<siteMapNode url="~/Membership/CreatingUserAccounts.aspx"
title="Create User" />
<siteMapNode url="~/Membership/PagePermission.aspx"
title="Authorisation" />
</siteMapNode>
<siteMapNode title="MIS">
<siteMapNode url="~/MIS.aspx" title="MIS" />
<siteMapNode url="~/Department.aspx" title="Department" />
<siteMapNode url="~/IRFReport.aspx" title="Test" />
</siteMapNode>
</siteMapNode>
</siteMap>
Want to hide or remove one or 2 node on page Load
pls help

Hi
I tried this code for the above problem

Protected Sub menu_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
menu.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim flLink1 As HyperLink = e.Item.FindControl("~/
IRF.aspx")
flLink1.Visible = False
End If
End Sub

but giving Error {"Object reference not set to an instance of an
object."}
 
E

Eliyahu Goldin

FindControl finds by id. Use

Dim flLink1 As HyperLink = e.Item.FindControl("HyperLink2")

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Ahmd said:
To change the number of shown items, it is usually better to operate on
the
datasource than on the bound control.

If you insist on doing that on the repeater, handle the ItemDataBound
event,
use FindControl method to locate the hyperlink inside the item and set
the
hyperlink's Visible property to false.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net


I have a Repeater to which a sitemap is bound, i want to remove or
hide any node while form load
<asp:Repeater runat="server" ID="menu"
DataSourceID="SiteMapDataSource1" EnableViewState="False">
<ItemTemplate>
<li>
<asp:HyperLink ID="HyperLink1"
runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></
asp:HyperLink>
<asp:Repeater ID="Repeater1"
runat="server" DataSource='<%# CType(Container.DataItem,
SiteMapNode).ChildNodes %>'>
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink
ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("Url") %>'><%#
Eval("Title") %></asp:HyperLink>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
</asp:Repeater>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
ShowStartingNode="false" />
I have the site map attached to the repeater.
site map
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"
<siteMapNode url="~/Default.aspx" title="Home" description="">
<siteMapNode title="IRF / IDF ">
<siteMapNode url="~/IRF.aspx" title="IR Form" />
<siteMapNode url="~/IDF.aspx" title="ID Form" />
</siteMapNode>
<siteMapNode title="Membership">
<siteMapNode url="~/Membership/CreatingUserAccounts.aspx"
title="Create User" />
<siteMapNode url="~/Membership/PagePermission.aspx"
title="Authorisation" />
</siteMapNode>
<siteMapNode title="MIS">
<siteMapNode url="~/MIS.aspx" title="MIS" />
<siteMapNode url="~/Department.aspx" title="Department" />
<siteMapNode url="~/IRFReport.aspx" title="Test" />
</siteMapNode>
</siteMapNode>
</siteMap>
Want to hide or remove one or 2 node on page Load
pls help

Hi
I tried this code for the above problem

Protected Sub menu_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
menu.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim flLink1 As HyperLink = e.Item.FindControl("~/
IRF.aspx")
flLink1.Visible = False
End If
End Sub

but giving Error {"Object reference not set to an instance of an
object."}
 
A

Ahmd

FindControl finds by id. Use

Dim flLink1 As HyperLink = e.Item.FindControl("HyperLink2")

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net


To change the number of shown items, it is usually better to operate on
the
datasource than on the bound control.
If you insist on doing that on the repeater, handle the ItemDataBound
event,
use FindControl method to locate the hyperlink inside the item and set
the
hyperlink's Visible property to false.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

I have a Repeater to which a sitemap is bound, i want to remove or
hide any node while form load
<asp:Repeater runat="server" ID="menu"
DataSourceID="SiteMapDataSource1" EnableViewState="False">
<ItemTemplate>
<li>
<asp:HyperLink ID="HyperLink1"
runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></
asp:HyperLink>
<asp:Repeater ID="Repeater1"
runat="server" DataSource='<%# CType(Container.DataItem,
SiteMapNode).ChildNodes %>'>
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink
ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("Url") %>'><%#
Eval("Title") %></asp:HyperLink>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
</asp:Repeater>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
ShowStartingNode="false" />
I have the site map attached to the repeater.
site map
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"
<siteMapNode url="~/Default.aspx" title="Home" description="">
<siteMapNode title="IRF / IDF ">
<siteMapNode url="~/IRF.aspx" title="IR Form" />
<siteMapNode url="~/IDF.aspx" title="ID Form" />
</siteMapNode>
<siteMapNode title="Membership">
<siteMapNode url="~/Membership/CreatingUserAccounts.aspx"
title="Create User" />
<siteMapNode url="~/Membership/PagePermission.aspx"
title="Authorisation" />
</siteMapNode>
<siteMapNode title="MIS">
<siteMapNode url="~/MIS.aspx" title="MIS" />
<siteMapNode url="~/Department.aspx" title="Department" />
<siteMapNode url="~/IRFReport.aspx" title="Test" />
</siteMapNode>
</siteMapNode>
</siteMap>
Want to hide or remove one or 2 node on page Load
pls help
Hi
I tried this code for the above problem
Protected Sub menu_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
menu.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim flLink1 As HyperLink = e.Item.FindControl("~/
IRF.aspx")
flLink1.Visible = False
End If
End Sub
but giving Error {"Object reference not set to an instance of an
object."}

i have to check for "MIS" in this hyperlink3 control and disable it.
pls explain me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top