You're welcome Shimon,
Have a nice day!
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Shimon Sim" <sh**********@community.nospam>
| References: <eO**************@tk2msftngp13.phx.gbl>
<Dw**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Link button in repeater header
| Date: Thu, 18 Aug 2005 08:19:12 -0400
| Lines: 159
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <e2**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:118839
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Yes, you I right.
| The problem was that I disabled view state for the repeater so the control
| was never created after post back.
| Thank you,
| Shimon.
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:Dw**************@TK2MSFTNGXA01.phx.gbl...
| > Hi Shimon,
| >
| > Welcome to ASPNET newsgroup.
| > As for the event handler of the repeater nested linkbutton not work
| > problem, I'm thinking whether its a page specific problem. Generally,
for
| > such sub control, we can register event handler for them through :
| >
| > 1. inline attribute in aspx page as you mentioned
| >
| > 2. programmatically register event handler in the repeater's ItemCreated
| > event.
| >
| > To make it clear, I've made a simple test page which demonstrate both
the
| > two means, you can have a test on your side to see whether there're any
| > difference between your problem page. Here is the code, hope helps:
| >
| > =======aspx========
| > <HTML>
| > <HEAD>
| > <title>simplerepeater</title>
| > <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
| > <meta name="CODE_LANGUAGE" Content="C#">
| > <meta name="vs_defaultClientScript" content="JavaScript">
| > <meta name="vs_targetSchema"
| > content="http://schemas.microsoft.com/intellisense/ie5">
| > </HEAD>
| > <body>
| > <form id="Form1" method="post" runat="server">
| > <asp:Repeater id="rptMain" runat="server">
| > <HeaderTemplate>
| > <br>
| > <hr>
| > <br>
| > <asp:LinkButton ID="btnStatic" Runat="server"
| > OnClick="btnStatic_Click">Static Handler</asp:LinkButton>
| > <asp:LinkButton ID="btnDynamic" Runat="server">Dynamic
| > Handler</asp:LinkButton>
| > <br>
| > <hr>
| > </HeaderTemplate>
| > <ItemTemplate>
| > <br>
| > <%# Container.DataItem %>
| > </ItemTemplate>
| > </asp:Repeater>
| > </form>
| > </body>
| > </HTML>
| >
| > ========code behind=======
| > public class simplerepeater : System.Web.UI.Page
| > {
| > protected System.Web.UI.WebControls.Repeater rptMain;
| >
| > private void Page_Load(object sender, System.EventArgs e)
| > {
| > if(!IsPostBack)
| > {
| > string[] items = {"aaa","bbb","ccc","ddd","eee","fff"};
| > rptMain.DataSource = items;
| > rptMain.DataBind();
| > }
| > }
| >
| >
| > protected void btnStatic_Click(object sender, EventArgs e)
| > {
| > Response.Write("<br>Static Link Button is clicked!");
| > }
| >
| > protected void btnDynamic_Click(object sender, EventArgs e)
| > {
| > Response.Write("<br>Dynamic Link Button is clicked!");
| > }
| >
| >
| > #region Web Form Designer generated code
| > override protected void OnInit(EventArgs e)
| > {
| > //
| > // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| > //
| > InitializeComponent();
| > base.OnInit(e);
| > }
| >
| > /// <summary>
| > /// Required method for Designer support - do not modify
| > /// the contents of this method with the code editor.
| > /// </summary>
| > private void InitializeComponent()
| > {
| > this.rptMain.ItemCreated += new
| >
System.Web.UI.WebControls.RepeaterItemEventHandler (this.rptMain_ItemCreated)
| > ;
| > this.Load += new System.EventHandler(this.Page_Load);
| >
| > }
| > #endregion
| >
| > private void rptMain_ItemCreated(object sender,
| > System.Web.UI.WebControls.RepeaterItemEventArgs e)
| > {
| > if(e.Item.ItemType == ListItemType.Header)
| > {
| > LinkButton btn = e.Item.FindControl("btnDynamic") as LinkButton;
| > if(btn != null)
| > {
| > btn.Click +=new EventHandler(btnDynamic_Click);
| > }
| > }
| > }
| > }
| >
| >
| >
| > --------------------
| > | From: "Shimon Sim" <sh**********@community.nospam>
| > | Subject: Link button in repeater header
| > | Date: Wed, 17 Aug 2005 23:20:21 -0400
| > | Lines: 10
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Original
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | Message-ID: <eO**************@tk2msftngp13.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:118785
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | I put linkbutton in a repeater header. I attached event handler in
| > makeup
| > as
| > | onclick="btnSort_Click".
| > | Made btnSort_Click method public. It doesn't fire if I click on it. I
| > tried
| > | to attach it in ItemDataBound event but I think it is too late.
| > |
| > | What am I doing wrong?
| > | Thanks
| > | Shimon.
| > |
| > |
| > |
| >
|
|
|