Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 7th, 2004, 09:15 PM
Registered User
 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Repeater with TextBox

Farily simple question, I think, but am stuck and would appreciate some help. The goal of the page is this: a dropdown box, from which 1 to 30 can be selected, and from the number selected a corresponding number of textboxes generated. The user will enter data in each text box, the data averaged and the average displayed.

The code is below. There are two main areas in which I'm not sure how to proceed.
1) In the BuildDataEntryForm subroutine (triggered by the onSelectedIndexChanged event of the dropdownlist), I attempt to build out a series of textboxes. However, the code below produces the following result (or something similar):

System.Web.UI.WebControls.TextBoxEnter Value System.Web.UI.WebControls.TextBoxEnter Value System.Web.UI.WebControls.TextBoxEnter Value ... ... ...

That is, it displays the reference names of the textboxes, but does not actually place a textbox in the form.

2) In the Calculate routine, I simply want to retrieve the values from each of the textboxes, convert them to numeric form, and calculate an average. However, given the above there are no textboxes from which the values can be extracted.

I hope that explains the issue sufficiently. Any help will be appreciated.

The code is copied below:

<Script Language="VB" Runat="Server" >
    Sub Page_Load()
            If Not Page.IsPostback Then
                txtLabel1.Visible = False
                btnCalculate.Visible = False
        Dim ListIndex = New ArrayList
        Dim intX as Integer
                For intX = 1 to 30
                     ListIndex.Add(intX)
                Next intX
                ListIndex.TrimToSize()
                lstDropDown.DataSource=ListIndex
                lstDropDown.DataBind()
            End If
          lstDropDown.AutoPostBack = True
    End Sub

        Sub BuildDataEntryForm(Source As Object, e as EventArgs)
            txtLabel1.Visible = False
            btnCalculate.Visible = True
            Dim intX As Integer
            Dim arrList = New ArrayList
            For intX = 1 to lstDropDown.SelectedItem.Value
                arrList.add(new TextBox())
            Next intX
            rptRepeater.DataSource=arrList
            rptRepeater.DataBind()
        End Sub

        Sub Calculate(Source As Object, e As EventArgs)
            Dim strTemp as String = ""
            Dim txtTemp as New TextBox()
            txtLabel1.Visible = True
            For Each item As RepeaterItem In rptRepeater.Items

'**** Not Sure What Should Go Here

            Next item
            Response.Write(txtTemp)
        End Sub

</script>

<html>
<body>
   <h3>Enter the numbers to be averaged</h3>
   <form Runat="Server">
      <asp:dropdownlist id="lstDropDown" Runat="Server" onSelectedIndexChanged="BuildDataEntryForm" /> <br />
      <asp:Repeater id="rptRepeater" Runat="Server">
          <ItemTemplate>
              <%#Container.DataItem%>Enter Value
          </ItemTemplate>
      </asp:Repeater>
      <asp:Button id="btnCalculate" Runat="Server" OnClick="Calculate" Text="Calculate Average" />
      <br />
      <asp:textbox id="txtLabel1" Runat="Server" />
   </form>
</body>

</html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
pointing cursor from one textbox to other textbox lakshmi_annayappa ASP.NET 1.0 and 1.1 Basics 2 August 2nd, 2007 03:41 PM
Masked TextBox & formatting TextBox melvik C# 1 September 22nd, 2003 11:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.