Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > linkbutton in nested repeater doesnt fire

Reply
Thread Tools

linkbutton in nested repeater doesnt fire

 
 
Nicolas Chevet
Guest
Posts: n/a
 
      10-17-2003
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_RE CURSIVE")%>'>
<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>


 
Reply With Quote
 
 
 
 
Patrik Lindholm
Guest
Posts: n/a
 
      10-17-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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_RE CURSIVE")%>'>
> <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>
>
>



 
Reply With Quote
 
 
 
 
Patrik Lindholm
Guest
Posts: n/a
 
      10-17-2003
Sorry I did not read it all

Regards Patrik

"Patrik Lindholm" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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_RE CURSIVE")%>'>
> > <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>
> >
> >

>
>



 
Reply With Quote
 
Nicolas Chevet
Guest
Posts: n/a
 
      10-17-2003
It works fine with the datalist but not with the linkbutton in the nested
repeater.
Any solution?


"Patrik Lindholm" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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_RE CURSIVE")%>'>
> > <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>
> >
> >

>
>



 
Reply With Quote
 
Patrik Lindholm
Guest
Posts: n/a
 
      10-17-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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_RE CURSIVE")%>'>
> <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>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sort list doesnt work, key=str still doesnt work notnorwegian@yahoo.se Python 3 05-27-2008 04:32 AM
PC doesnt boot first time and doesnt shutdown dann Computer Support 6 08-21-2006 07:31 AM
Linkbutton does not look like a linkbutton Sathyaish ASP .Net 3 09-08-2005 09:41 AM
Repeater control with nested repeater chris.reed@digus.com ASP .Net 0 02-11-2005 05:10 PM
linkbutton in nested repeater doesnt fire Nicolas Chevet ASP .Net Web Controls 4 10-17-2003 02:13 PM



Advertisments