asp.net - Why is the footer-item not included in Repeater.Items? -


I need to get a value from a text box inside the footer template in an OnClick event of a button. My first thought was to loop through the objects-property on my repeater, but as you can see in this sample, it contains only the actual data items, not the footer item.

ASPX:

  & lt; Asp: repeater id = "repeater 1" runat = "server" & gt; & Lt; ItemTemplate & gt; Item & lt; Br / & gt; & Lt; / ItemTemplate & gt; & Lt; FooterTemplate & gt; Footer & lt; Br / & gt; & Lt; ASP: Text Box ID = "Text Box 1" Runat = "Server" & gt; & Lt; / Asp: text box & gt; & Lt; / FooterTemplate & gt; & Lt; / ASP: Repeater & gt; & Lt; ASP: Button ID = "Button 1" Runat = "Server" Text = "Button" OnClick = "Button 1_Click" />  

Code-behind CCS:

  Protected Zero Page_load (Object Sender, EventArgues E) {ListItemCollection items = new ListItemCollection (); Items.Add ("value1"); Items.Add ("value2"); Repeater 1 Data source = item; Repeater1.DataBind (); } Secure Zero Button 1_Click (Object Sender, EventArgs e) {System.Diagnostics.Debug.WriteLine (Repeater1.Items.Count); }  

This code will output to "2" as count only, how do I reference my text box inside the footsteps? From

, the item is only a set of repeaters depending on the datasource which you are binding and the headers or footers Articles are not included in the template.

If you want to referenced the text box, you can get a reference from the repeat item itemboot event where you can test for the footer.

Example

  Private ZERO RECITATOR_ITEM DATABOUND (Object Sender, Repeater Item Event ARG E) {if (e.Item.ItemType == ListItemType.Footer) {Textbox textbox = E.Item FindControl as TextCox ("Textbox1"); }}  

Comments