Repeater Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ahmd

    Repeater Problem

    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="S iteMapDataSourc e1" EnableViewState ="False">
    <ItemTemplate >
    <li>
    <asp:HyperLin k ID="HyperLink1 "
    runat="server" NavigateUrl='<% # Eval("Url") %>'><%# Eval("Title") %></
    asp:HyperLink>

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

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

    <FooterTemplate >
    </ul>
    </FooterTemplate>
    </asp:Repeater>
    </li>
    </ItemTemplate>
    </asp:Repeater>
    <asp:SiteMapDat aSource ID="SiteMapData Source1" runat="server"
    ShowStartingNod e="false" />

    I have the site map attached to the repeater.

    site map
    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microso ft.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="Membersh ip">
    <siteMapNode url="~/Membership/CreatingUserAcc ounts.aspx"
    title="Create User" />
    <siteMapNode url="~/Membership/PagePermission. aspx"
    title="Authoris ation" />
    </siteMapNode>
    <siteMapNode title="MIS">
    <siteMapNode url="~/MIS.aspx" title="MIS" />
    <siteMapNode url="~/Department.aspx " title="Departme nt" />
    <siteMapNode url="~/IRFReport.aspx" title="Test" />
    </siteMapNode>
    </siteMapNode>
    </siteMap>


    Want to hide or remove one or 2 node on page Load
    pls help
  • Eliyahu Goldin

    #2
    Re: Repeater Problem

    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]




    "Ahmd" <mkahmed77@gmai l.comwrote in message
    news:e235e53d-1383-485c-a6de-478d5592e969@z6 6g2000hsc.googl egroups.com...
    >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="S iteMapDataSourc e1" EnableViewState ="False">
    <ItemTemplate >
    <li>
    <asp:HyperLin k ID="HyperLink1 "
    runat="server" NavigateUrl='<% # Eval("Url") %>'><%# Eval("Title") %></
    asp:HyperLink>
    >
    <asp:Repeater ID="Repeater1"
    runat="server" DataSource='<%# CType(Container .DataItem,
    SiteMapNode).Ch ildNodes %>'>
    <HeaderTemplate >
    <ul>
    </HeaderTemplate>
    >
    <ItemTemplate >
    <li>
    <asp:HyperLin k
    ID="HyperLink2 " runat="server" NavigateUrl='<% # Eval("Url") %>'><%#
    Eval("Title") %></asp:HyperLink>
    </li>
    </ItemTemplate>
    >
    <FooterTemplate >
    </ul>
    </FooterTemplate>
    </asp:Repeater>
    </li>
    </ItemTemplate>
    </asp:Repeater>
    <asp:SiteMapDat aSource ID="SiteMapData Source1" runat="server"
    ShowStartingNod e="false" />
    >
    I have the site map attached to the repeater.
    >
    site map
    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microso ft.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="Membersh ip">
    <siteMapNode url="~/Membership/CreatingUserAcc ounts.aspx"
    title="Create User" />
    <siteMapNode url="~/Membership/PagePermission. aspx"
    title="Authoris ation" />
    </siteMapNode>
    <siteMapNode title="MIS">
    <siteMapNode url="~/MIS.aspx" title="MIS" />
    <siteMapNode url="~/Department.aspx " title="Departme nt" />
    <siteMapNode url="~/IRFReport.aspx" title="Test" />
    </siteMapNode>
    </siteMapNode>
    </siteMap>
    >
    >
    Want to hide or remove one or 2 node on page Load
    pls help

    Comment

    • Ahmd

      #3
      Re: Repeater Problem

      On May 26, 12:52 pm, "Eliyahu Goldin"
      <REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
      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
      >
      "Ahmd" <mkahme...@gmai l.comwrote in message
      >
      news:e235e53d-1383-485c-a6de-478d5592e969@z6 6g2000hsc.googl egroups.com...
      >
      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="S iteMapDataSourc e1" EnableViewState ="False">
      <ItemTemplate >
      <li>
      <asp:HyperLin k ID="HyperLink1 "
      runat="server" NavigateUrl='<% # Eval("Url") %>'><%# Eval("Title") %></
      asp:HyperLink>
      >
      <asp:Repeater ID="Repeater1"
      runat="server" DataSource='<%# CType(Container .DataItem,
      SiteMapNode).Ch ildNodes %>'>
      <HeaderTemplate >
      <ul>
      </HeaderTemplate>
      >
      <ItemTemplate >
      <li>
      <asp:HyperLin k
      ID="HyperLink2 " runat="server" NavigateUrl='<% # Eval("Url") %>'><%#
      Eval("Title") %></asp:HyperLink>
      </li>
      </ItemTemplate>
      >
      <FooterTemplate >
      </ul>
      </FooterTemplate>
      </asp:Repeater>
      </li>
      </ItemTemplate>
      </asp:Repeater>
      <asp:SiteMapDat aSource ID="SiteMapData Source1" runat="server"
      ShowStartingNod e="false" />
      >
      I have the site map attached to the repeater.
      >
      site map
      <?xml version="1.0" encoding="utf-8" ?>
      <siteMap xmlns="http://schemas.microso ft.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="Membersh ip">
      <siteMapNode url="~/Membership/CreatingUserAcc ounts.aspx"
      title="Create User" />
      <siteMapNode url="~/Membership/PagePermission. aspx"
      title="Authoris ation" />
      </siteMapNode>
      <siteMapNode title="MIS">
      <siteMapNode url="~/MIS.aspx" title="MIS" />
      <siteMapNode url="~/Department.aspx " title="Departme nt" />
      <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_ItemDataBo und(ByVal sender As Object, ByVal e As
      System.Web.UI.W ebControls.Repe aterItemEventAr gs) Handles
      menu.ItemDataBo und
      If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
      ListItemType.Al ternatingItem Then
      Dim flLink1 As HyperLink = e.Item.FindCont rol("~/
      IRF.aspx")
      flLink1.Visible = False
      End If
      End Sub

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

      Comment

      • Eliyahu Goldin

        #4
        Re: Repeater Problem

        FindControl finds by id. Use

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

        --
        Eliyahu Goldin,
        Software Developer
        Microsoft MVP [ASP.NET]




        "Ahmd" <mkahmed77@gmai l.comwrote in message
        news:f8fce788-44e5-4ee5-8831-356dcba0589b@l6 4g2000hse.googl egroups.com...
        On May 26, 12:52 pm, "Eliyahu Goldin"
        <REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
        >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
        >>
        >"Ahmd" <mkahme...@gmai l.comwrote in message
        >>
        >news:e235e53 d-1383-485c-a6de-478d5592e969@z6 6g2000hsc.googl egroups.com...
        >>
        >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="S iteMapDataSourc e1" EnableViewState ="False">
        <ItemTemplate >
        <li>
        <asp:HyperLin k ID="HyperLink1 "
        runat="server" NavigateUrl='<% # Eval("Url") %>'><%# Eval("Title") %></
        asp:HyperLink>
        >>
        <asp:Repeater ID="Repeater1"
        runat="server" DataSource='<%# CType(Container .DataItem,
        SiteMapNode).Ch ildNodes %>'>
        <HeaderTemplate >
        <ul>
        </HeaderTemplate>
        >>
        <ItemTemplate >
        <li>
        <asp:HyperLin k
        ID="HyperLink2 " runat="server" NavigateUrl='<% # Eval("Url") %>'><%#
        Eval("Title") %></asp:HyperLink>
        </li>
        </ItemTemplate>
        >>
        <FooterTemplate >
        </ul>
        </FooterTemplate>
        </asp:Repeater>
        </li>
        </ItemTemplate>
        </asp:Repeater>
        <asp:SiteMapDat aSource ID="SiteMapData Source1" runat="server"
        ShowStartingNod e="false" />
        >>
        I have the site map attached to the repeater.
        >>
        site map
        <?xml version="1.0" encoding="utf-8" ?>
        <siteMap xmlns="http://schemas.microso ft.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="Membersh ip">
        <siteMapNode url="~/Membership/CreatingUserAcc ounts.aspx"
        title="Create User" />
        <siteMapNode url="~/Membership/PagePermission. aspx"
        title="Authoris ation" />
        </siteMapNode>
        <siteMapNode title="MIS">
        <siteMapNode url="~/MIS.aspx" title="MIS" />
        <siteMapNode url="~/Department.aspx " title="Departme nt" />
        <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_ItemDataBo und(ByVal sender As Object, ByVal e As
        System.Web.UI.W ebControls.Repe aterItemEventAr gs) Handles
        menu.ItemDataBo und
        If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
        ListItemType.Al ternatingItem Then
        Dim flLink1 As HyperLink = e.Item.FindCont rol("~/
        IRF.aspx")
        flLink1.Visible = False
        End If
        End Sub
        >
        but giving Error {"Object reference not set to an instance of an
        object."}

        Comment

        • Ahmd

          #5
          Re: Repeater Problem

          On May 27, 12:41 pm, "Eliyahu Goldin"
          <REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
          FindControl finds by id. Use
          >
          Dim flLink1 As HyperLink = e.Item.FindCont rol("HyperLink2 ")
          >
          --
          Eliyahu Goldin,
          Software Developer
          Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
          >
          "Ahmd" <mkahme...@gmai l.comwrote in message
          >
          news:f8fce788-44e5-4ee5-8831-356dcba0589b@l6 4g2000hse.googl egroups.com...
          >
          On May 26, 12:52 pm, "Eliyahu Goldin"
          <REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
          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
          >
          "Ahmd" <mkahme...@gmai l.comwrote in message
          >
          >news:e235e53 d-1383-485c-a6de-478d5592e969@z6 6g2000hsc.googl egroups.com...
          >
          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="S iteMapDataSourc e1" EnableViewState ="False">
          <ItemTemplate >
          <li>
          <asp:HyperLin k ID="HyperLink1 "
          runat="server" NavigateUrl='<% # Eval("Url") %>'><%# Eval("Title") %></
          asp:HyperLink>
          >
          <asp:Repeater ID="Repeater1"
          runat="server" DataSource='<%# CType(Container .DataItem,
          SiteMapNode).Ch ildNodes %>'>
          <HeaderTemplate >
          <ul>
          </HeaderTemplate>
          >
          <ItemTemplate >
          <li>
          <asp:HyperLin k
          ID="HyperLink2 " runat="server" NavigateUrl='<% # Eval("Url") %>'><%#
          Eval("Title") %></asp:HyperLink>
          </li>
          </ItemTemplate>
          >
          <FooterTemplate >
          </ul>
          </FooterTemplate>
          </asp:Repeater>
          </li>
          </ItemTemplate>
          </asp:Repeater>
          <asp:SiteMapDat aSource ID="SiteMapData Source1" runat="server"
          ShowStartingNod e="false" />
          >
          I have the site map attached to the repeater.
          >
          site map
          <?xml version="1.0" encoding="utf-8" ?>
          <siteMap xmlns="http://schemas.microso ft.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="Membersh ip">
          <siteMapNode url="~/Membership/CreatingUserAcc ounts.aspx"
          title="Create User" />
          <siteMapNode url="~/Membership/PagePermission. aspx"
          title="Authoris ation" />
          </siteMapNode>
          <siteMapNode title="MIS">
          <siteMapNode url="~/MIS.aspx" title="MIS" />
          <siteMapNode url="~/Department.aspx " title="Departme nt" />
          <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_ItemDataBo und(ByVal sender As Object, ByVal e As
          System.Web.UI.W ebControls.Repe aterItemEventAr gs) Handles
          menu.ItemDataBo und
          If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
          ListItemType.Al ternatingItem Then
          Dim flLink1 As HyperLink = e.Item.FindCont rol("~/
          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

          Comment

          Working...