linkbutton in nested repeater doesnt fire

Discussion in 'ASP .Net Datagrid Control' started by Nicolas Chevet, Oct 17, 2003.

  1. Hi!
    I've got a page with a datalist and a nested repeater in it to get
    "categories" and "sub categories".
    I've got link button in the datalist and in the repeater. The ones in the
    datalist work fine assuming it fire itemcommand event on postback. The
    problem is that the link button in the nested repeater doesnt raise any
    event.

    How can i catch the click event of the nested link button?
    Thanks a lot.

    Here's a piece of code:

    <asp:datalist id="CategorieList" runat="server" HorizontalAlign="Center"
    Width="90%" RepeatColumns="2"
    BorderWidth="1px" GridLines="Horizontal" CellPadding="3"
    BackColor="White" BorderStyle="None"
    BorderColor="#E7E7FF">
    <ItemTemplate>
    <B>
    <asp:LinkButton id=LinkFonction runat="server"
    CommandName='<%#DataBinder.Eval( Container.DataItem, "strNom" )%>'
    CommandArgument='<%#DataBinder.Eval( Container.DataItem,
    "intIdCategorie" )%>'>
    <%# DataBinder.Eval(Container.DataItem,"strNom") %>
    &nbsp;(<%# DataBinder.Eval(Container.DataItem, "intIdCategorie") %>)
    </asp:LinkButton></B><BR>
    <asp:Repeater id=Repeater1 runat="server" DataSource='<%#
    GetChildRelation(Container.DataItem,"CATEGORIES_RECURSIVE")%>'>
    <itemTemplate>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <asp:LinkButton id="Linkbutton1" CommandName='<%#DataBinder.Eval(
    Container.DataItem, "strNom" )%>' CommandArgument='<%#DataBinder.Eval(
    Container.DataItem, "intIdCategorie" )%>' runat="server">
    <%# DataBinder.Eval(Container.DataItem,"strNom") %>
    &nbsp;(<%# DataBinder.Eval(Container.DataItem, "intIdCategorie") %>)
    </asp:LinkButton><br>
    </itemTemplate>
    </asp:Repeater>
    </ItemTemplate>
    </asp:datalist>
     
    Nicolas Chevet, Oct 17, 2003
    #1
    1. Advertising

  2. Hi Nicolas!

    For the DataList you have an event called ItemCommand with the usual
    object source parameter and DataListCommandEventArgs e

    if you have a linkbutton named LinkButton1 in the datalist you can use the
    following code

    LinkButton linkButton = (LinkButton)e.FindControl("LinkButton1")

    this way you get the linkbutton you cklicked on

    Hope this helps

    Regards Patrik


    "Nicolas Chevet" <> wrote in message
    news:...
    > Hi!
    > I've got a page with a datalist and a nested repeater in it to get
    > "categories" and "sub categories".
    > I've got link button in the datalist and in the repeater. The ones in the
    > datalist work fine assuming it fire itemcommand event on postback. The
    > problem is that the link button in the nested repeater doesnt raise any
    > event.
    >
    > How can i catch the click event of the nested link button?
    > Thanks a lot.
    >
    > Here's a piece of code:
    >
    > <asp:datalist id="CategorieList" runat="server" HorizontalAlign="Center"
    > Width="90%" RepeatColumns="2"
    > BorderWidth="1px" GridLines="Horizontal" CellPadding="3"
    > BackColor="White" BorderStyle="None"
    > BorderColor="#E7E7FF">
    > <ItemTemplate>
    > <B>
    > <asp:LinkButton id=LinkFonction runat="server"
    > CommandName='<%#DataBinder.Eval( Container.DataItem, "strNom" )%>'
    > CommandArgument='<%#DataBinder.Eval( Container.DataItem,
    > "intIdCategorie" )%>'>
    > <%# DataBinder.Eval(Container.DataItem,"strNom") %>
    > &nbsp;(<%# DataBinder.Eval(Container.DataItem, "intIdCategorie") %>)
    > </asp:LinkButton></B><BR>
    > <asp:Repeater id=Repeater1 runat="server" DataSource='<%#
    > GetChildRelation(Container.DataItem,"CATEGORIES_RECURSIVE")%>'>
    > <itemTemplate>
    > &nbsp;&nbsp;&nbsp;&nbsp;
    > <asp:LinkButton id="Linkbutton1" CommandName='<%#DataBinder.Eval(
    > Container.DataItem, "strNom" )%>' CommandArgument='<%#DataBinder.Eval(
    > Container.DataItem, "intIdCategorie" )%>' runat="server">
    > <%# DataBinder.Eval(Container.DataItem,"strNom") %>
    > &nbsp;(<%# DataBinder.Eval(Container.DataItem, "intIdCategorie") %>)
    > </asp:LinkButton><br>
    > </itemTemplate>
    > </asp:Repeater>
    > </ItemTemplate>
    > </asp:datalist>
    >
    >
     
    Patrik Lindholm, Oct 17, 2003
    #2
    1. Advertising

  3. Sorry I did not read it all

    Regards Patrik

    "Patrik Lindholm" <> wrote in message
    news:...
    > Hi Nicolas!
    >
    > For the DataList you have an event called ItemCommand with the usual
    > object source parameter and DataListCommandEventArgs e
    >
    > if you have a linkbutton named LinkButton1 in the datalist you can use the
    > following code
    >
    > LinkButton linkButton = (LinkButton)e.FindControl("LinkButton1")
    >
    > this way you get the linkbutton you cklicked on
    >
    > Hope this helps
    >
    > Regards Patrik
    >
    >
    > "Nicolas Chevet" <> wrote in message
    > news:...
    > > Hi!
    > > I've got a page with a datalist and a nested repeater in it to get
    > > "categories" and "sub categories".
    > > I've got link button in the datalist and in the repeater. The ones in

    the
    > > datalist work fine assuming it fire itemcommand event on postback. The
    > > problem is that the link button in the nested repeater doesnt raise any
    > > event.
    > >
    > > How can i catch the click event of the nested link button?
    > > Thanks a lot.
    > >
    > > Here's a piece of code:
    > >
    > > <asp:datalist id="CategorieList" runat="server" HorizontalAlign="Center"
    > > Width="90%" RepeatColumns="2"
    > > BorderWidth="1px" GridLines="Horizontal" CellPadding="3"
    > > BackColor="White" BorderStyle="None"
    > > BorderColor="#E7E7FF">
    > > <ItemTemplate>
    > > <B>
    > > <asp:LinkButton id=LinkFonction runat="server"
    > > CommandName='<%#DataBinder.Eval( Container.DataItem, "strNom" )%>'
    > > CommandArgument='<%#DataBinder.Eval( Container.DataItem,
    > > "intIdCategorie" )%>'>
    > > <%# DataBinder.Eval(Container.DataItem,"strNom") %>
    > > &nbsp;(<%# DataBinder.Eval(Container.DataItem, "intIdCategorie")

    %>)
    > > </asp:LinkButton></B><BR>
    > > <asp:Repeater id=Repeater1 runat="server" DataSource='<%#
    > > GetChildRelation(Container.DataItem,"CATEGORIES_RECURSIVE")%>'>
    > > <itemTemplate>
    > > &nbsp;&nbsp;&nbsp;&nbsp;
    > > <asp:LinkButton id="Linkbutton1" CommandName='<%#DataBinder.Eval(
    > > Container.DataItem, "strNom" )%>' CommandArgument='<%#DataBinder.Eval(
    > > Container.DataItem, "intIdCategorie" )%>' runat="server">
    > > <%# DataBinder.Eval(Container.DataItem,"strNom") %>
    > > &nbsp;(<%# DataBinder.Eval(Container.DataItem, "intIdCategorie")

    %>)
    > > </asp:LinkButton><br>
    > > </itemTemplate>
    > > </asp:Repeater>
    > > </ItemTemplate>
    > > </asp:datalist>
    > >
    > >

    >
    >
     
    Patrik Lindholm, Oct 17, 2003
    #3
  4. It works fine with the datalist but not with the linkbutton in the nested
    repeater.
    Any solution?


    "Patrik Lindholm" <> wrote in message
    news:...
    > Hi Nicolas!
    >
    > For the DataList you have an event called ItemCommand with the usual
    > object source parameter and DataListCommandEventArgs e
    >
    > if you have a linkbutton named LinkButton1 in the datalist you can use the
    > following code
    >
    > LinkButton linkButton = (LinkButton)e.FindControl("LinkButton1")
    >
    > this way you get the linkbutton you cklicked on
    >
    > Hope this helps
    >
    > Regards Patrik
    >
    >
    > "Nicolas Chevet" <> wrote in message
    > news:...
    > > Hi!
    > > I've got a page with a datalist and a nested repeater in it to get
    > > "categories" and "sub categories".
    > > I've got link button in the datalist and in the repeater. The ones in

    the
    > > datalist work fine assuming it fire itemcommand event on postback. The
    > > problem is that the link button in the nested repeater doesnt raise any
    > > event.
    > >
    > > How can i catch the click event of the nested link button?
    > > Thanks a lot.
    > >
    > > Here's a piece of code:
    > >
    > > <asp:datalist id="CategorieList" runat="server" HorizontalAlign="Center"
    > > Width="90%" RepeatColumns="2"
    > > BorderWidth="1px" GridLines="Horizontal" CellPadding="3"
    > > BackColor="White" BorderStyle="None"
    > > BorderColor="#E7E7FF">
    > > <ItemTemplate>
    > > <B>
    > > <asp:LinkButton id=LinkFonction runat="server"
    > > CommandName='<%#DataBinder.Eval( Container.DataItem, "strNom" )%>'
    > > CommandArgument='<%#DataBinder.Eval( Container.DataItem,
    > > "intIdCategorie" )%>'>
    > > <%# DataBinder.Eval(Container.DataItem,"strNom") %>
    > > &nbsp;(<%# DataBinder.Eval(Container.DataItem, "intIdCategorie")

    %>)
    > > </asp:LinkButton></B><BR>
    > > <asp:Repeater id=Repeater1 runat="server" DataSource='<%#
    > > GetChildRelation(Container.DataItem,"CATEGORIES_RECURSIVE")%>'>
    > > <itemTemplate>
    > > &nbsp;&nbsp;&nbsp;&nbsp;
    > > <asp:LinkButton id="Linkbutton1" CommandName='<%#DataBinder.Eval(
    > > Container.DataItem, "strNom" )%>' CommandArgument='<%#DataBinder.Eval(
    > > Container.DataItem, "intIdCategorie" )%>' runat="server">
    > > <%# DataBinder.Eval(Container.DataItem,"strNom") %>
    > > &nbsp;(<%# DataBinder.Eval(Container.DataItem, "intIdCategorie")

    %>)
    > > </asp:LinkButton><br>
    > > </itemTemplate>
    > > </asp:Repeater>
    > > </ItemTemplate>
    > > </asp:datalist>
    > >
    > >

    >
    >
     
    Nicolas Chevet, Oct 17, 2003
    #4
  5. Hi again Nicolas

    Now I've found a solution that works

    You have an event for the DataList called Item_Created if you do like this

    private void Repeater1_ItemCommand(object source,
    System.Web.UI.WebControls.RepeaterCommandEventArgs e)

    {

    // Lots of code

    }

    private void DataList1_ItemCreated(object sender,
    System.Web.UI.WebControls.DataListItemEventArgs e)

    {

    Repeater r = (Repeater)e.Item.FindControl("Repeater1");

    // Note that you have to add the eventhandler yourself

    r.ItemCommand += new RepeaterCommandEventHandler(Repeater1_ItemCommand);

    }

    Hope this helps




    "Nicolas Chevet" <> wrote in message
    news:...
    > Hi!
    > I've got a page with a datalist and a nested repeater in it to get
    > "categories" and "sub categories".
    > I've got link button in the datalist and in the repeater. The ones in the
    > datalist work fine assuming it fire itemcommand event on postback. The
    > problem is that the link button in the nested repeater doesnt raise any
    > event.
    >
    > How can i catch the click event of the nested link button?
    > Thanks a lot.
    >
    > Here's a piece of code:
    >
    > <asp:datalist id="CategorieList" runat="server" HorizontalAlign="Center"
    > Width="90%" RepeatColumns="2"
    > BorderWidth="1px" GridLines="Horizontal" CellPadding="3"
    > BackColor="White" BorderStyle="None"
    > BorderColor="#E7E7FF">
    > <ItemTemplate>
    > <B>
    > <asp:LinkButton id=LinkFonction runat="server"
    > CommandName='<%#DataBinder.Eval( Container.DataItem, "strNom" )%>'
    > CommandArgument='<%#DataBinder.Eval( Container.DataItem,
    > "intIdCategorie" )%>'>
    > <%# DataBinder.Eval(Container.DataItem,"strNom") %>
    > &nbsp;(<%# DataBinder.Eval(Container.DataItem, "intIdCategorie") %>)
    > </asp:LinkButton></B><BR>
    > <asp:Repeater id=Repeater1 runat="server" DataSource='<%#
    > GetChildRelation(Container.DataItem,"CATEGORIES_RECURSIVE")%>'>
    > <itemTemplate>
    > &nbsp;&nbsp;&nbsp;&nbsp;
    > <asp:LinkButton id="Linkbutton1" CommandName='<%#DataBinder.Eval(
    > Container.DataItem, "strNom" )%>' CommandArgument='<%#DataBinder.Eval(
    > Container.DataItem, "intIdCategorie" )%>' runat="server">
    > <%# DataBinder.Eval(Container.DataItem,"strNom") %>
    > &nbsp;(<%# DataBinder.Eval(Container.DataItem, "intIdCategorie") %>)
    > </asp:LinkButton><br>
    > </itemTemplate>
    > </asp:Repeater>
    > </ItemTemplate>
    > </asp:datalist>
    >
    >
     
    Patrik Lindholm, Oct 17, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. senglory
    Replies:
    1
    Views:
    432
    Jeffrey Palermo [MCP]
    Nov 29, 2004
  2. Sathyaish
    Replies:
    3
    Views:
    3,131
    Sathyaish
    Sep 8, 2005
  3. Replies:
    3
    Views:
    443
    alex23
    May 27, 2008
  4. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    201
    Sathyaish
    Sep 8, 2005
  5. Nicolas Chevet

    linkbutton in nested repeater doesnt fire

    Nicolas Chevet, Oct 17, 2003, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    223
    Patrik Lindholm
    Oct 17, 2003
Loading...

Share This Page