Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Need help with loading rows of input controls one at a time

Need help with loading rows of input controls one at a time

Scheduled Pinned Locked Moved ASP.NET
databasecsharpasp-nethelpquestion
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Eber
    wrote on last edited by
    #1

    To begin with I AM NOT AN ASP.NET Coder. So please bear with me and my questions. I have to build this in asp instead of silverlight so it can be accessed on blackberries. I have a page that collects a ton of data about where a link will be started. The engineers then construct 4-8 links to the endpoint terminus. What I'm trying to do is have each link get added to the list of links until they click the done button. Each 'link' in the list would be as follows: lable'Leg ' lable'nn' text' ' button[next link] button[done] the lable with the 'nn' value is populated by me and is 1, 2, 3, 4, etc. the button with [next link] would trigger adding the next set of lables, textbox, and buttons. the button with [done] would populate the database with all of the links. In a prior post I was given invalid control types to use and the person never answered me after that. So how would I do this in ASP.Net so that the input is always sent back to me and the next link is added to the list with each postback?

    N 1 Reply Last reply
    0
    • M Michael Eber

      To begin with I AM NOT AN ASP.NET Coder. So please bear with me and my questions. I have to build this in asp instead of silverlight so it can be accessed on blackberries. I have a page that collects a ton of data about where a link will be started. The engineers then construct 4-8 links to the endpoint terminus. What I'm trying to do is have each link get added to the list of links until they click the done button. Each 'link' in the list would be as follows: lable'Leg ' lable'nn' text' ' button[next link] button[done] the lable with the 'nn' value is populated by me and is 1, 2, 3, 4, etc. the button with [next link] would trigger adding the next set of lables, textbox, and buttons. the button with [done] would populate the database with all of the links. In a prior post I was given invalid control types to use and the person never answered me after that. So how would I do this in ASP.Net so that the input is always sent back to me and the next link is added to the list with each postback?

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      A few ways you could do it. Use a repeater control with a template that contains the label the textbox controls Pseudo code here <repeater>    <template>       <label>       <textbox>    </template> </repeater> <button value=Next><button value=Done> Bind the repeater to some collection. Handle the click event for the button and add an item to the   collection, then rebind to the repeater. Another way is to handle the click event for the button and add the next set of controls to the controls collection of the page.


      only two letters away from being an asset

      M 1 Reply Last reply
      0
      • N Not Active

        A few ways you could do it. Use a repeater control with a template that contains the label the textbox controls Pseudo code here <repeater>    <template>       <label>       <textbox>    </template> </repeater> <button value=Next><button value=Done> Bind the repeater to some collection. Handle the click event for the button and add an item to the   collection, then rebind to the repeater. Another way is to handle the click event for the button and add the next set of controls to the controls collection of the page.


        only two letters away from being an asset

        M Offline
        M Offline
        Michael Eber
        wrote on last edited by
        #3

        Mark, Thank you so much. I have everything almost working. After a little debugging I found I had to code a bit to rebuild the collection of values for each new connection added. Now I have just a tiny issue I cannot figure out. My logic is quite simple:

        	protected void NextLegEventHandler( object sender, EventArgs e )
        	{
        		LegItem legItem = new LegItem( );
        		legNames = new Dictionary<int, LegItem>( );
        		foreach ( Control item in LegConstructor.Controls )
        		{
        			if ( !( item is RepeaterItem ) ) continue;
        			if ( item.Controls.Count <= 1 ) continue;
        			foreach ( Control textItem in item.Controls )
        			{
        				TextBox currentControl = textItem as TextBox;
        				if ( currentControl == null ) continue;
        				int result = 0;
        				if ( Int32.TryParse( currentControl.Text, out result ) )
        				{
        					legItem = new LegItem( );
        					legItem.LegNumber = result;
        				}
        				else
        				{
        					legItem.PortName = currentControl.Text;
        					legNames.Add( legItem.LegNumber, legItem );
        				}
        			}
        
        		}
        		LegItem newLeg = new LegItem( );
        		newLeg.LegNumber = legNames.Count + 1;
        		newLeg.PortName = string.Empty;
        		legNames.Add( newLeg.LegNumber, newLeg );
        		this.LegConstructor.DataSource = legNames.Values.ToArray<LegItem>( );
        		this.LegConstructor.DataBind( );
        	}
        

        So this way I rebuild the values for each leg and rebind with the new list. The problem: I have to hit the button twice to get the new entry to display! What am I missing to force the page to display the new data once I complete my response to the event? Thanks again, Michael

        N 1 Reply Last reply
        0
        • M Michael Eber

          Mark, Thank you so much. I have everything almost working. After a little debugging I found I had to code a bit to rebuild the collection of values for each new connection added. Now I have just a tiny issue I cannot figure out. My logic is quite simple:

          	protected void NextLegEventHandler( object sender, EventArgs e )
          	{
          		LegItem legItem = new LegItem( );
          		legNames = new Dictionary<int, LegItem>( );
          		foreach ( Control item in LegConstructor.Controls )
          		{
          			if ( !( item is RepeaterItem ) ) continue;
          			if ( item.Controls.Count <= 1 ) continue;
          			foreach ( Control textItem in item.Controls )
          			{
          				TextBox currentControl = textItem as TextBox;
          				if ( currentControl == null ) continue;
          				int result = 0;
          				if ( Int32.TryParse( currentControl.Text, out result ) )
          				{
          					legItem = new LegItem( );
          					legItem.LegNumber = result;
          				}
          				else
          				{
          					legItem.PortName = currentControl.Text;
          					legNames.Add( legItem.LegNumber, legItem );
          				}
          			}
          
          		}
          		LegItem newLeg = new LegItem( );
          		newLeg.LegNumber = legNames.Count + 1;
          		newLeg.PortName = string.Empty;
          		legNames.Add( newLeg.LegNumber, newLeg );
          		this.LegConstructor.DataSource = legNames.Values.ToArray<LegItem>( );
          		this.LegConstructor.DataBind( );
          	}
          

          So this way I rebuild the values for each leg and rebind with the new list. The problem: I have to hit the button twice to get the new entry to display! What am I missing to force the page to display the new data once I complete my response to the event? Thanks again, Michael

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Why are you going through all of this :wtf: :omg: Maintain your collection (as in ViewState, Session, etc.), add one to it in the handler, then rebind. What is the dictionary for? You are only using the values from it.

          Michael Eber wrote:

          I AM NOT AN ASP.NET Coder.

          Whether you are an ASP.NET coder or not, someone with your professed skills and length of C# history should be able to figure this out. After writing a new multitasking operating system in Assembler this should be a walk in the park.


          only two letters away from being an asset

          M 2 Replies Last reply
          0
          • N Not Active

            Why are you going through all of this :wtf: :omg: Maintain your collection (as in ViewState, Session, etc.), add one to it in the handler, then rebind. What is the dictionary for? You are only using the values from it.

            Michael Eber wrote:

            I AM NOT AN ASP.NET Coder.

            Whether you are an ASP.NET coder or not, someone with your professed skills and length of C# history should be able to figure this out. After writing a new multitasking operating system in Assembler this should be a walk in the park.


            only two letters away from being an asset

            M Offline
            M Offline
            Michael Eber
            wrote on last edited by
            #5

            Sorry but I'm accustomed to writing code that is stateful where I can just access the datasource, cast it, and append to it. Web coding is a completely different animal. Regardless of HOW I am doing it, whether I figure out how to use ViewState or if I figure out Session, it does not change the fact that when I set my datasource and rebind it, my controls are not displaying until I hit the button twice, or slowly walk through the code in debug mode. Why is this happening? In a real application (ie. not a freaking web p.o.s.) this is always easily figured out. But I cannot figure out why I must hit the button twice to see my control. You say just rebind it. Well I am rebinding the fracking array. And it is not doing it. If you have something USEFUL to add, please I'm all ears. But if you don't then thank you for at least getting me this far.

            1 Reply Last reply
            0
            • N Not Active

              Why are you going through all of this :wtf: :omg: Maintain your collection (as in ViewState, Session, etc.), add one to it in the handler, then rebind. What is the dictionary for? You are only using the values from it.

              Michael Eber wrote:

              I AM NOT AN ASP.NET Coder.

              Whether you are an ASP.NET coder or not, someone with your professed skills and length of C# history should be able to figure this out. After writing a new multitasking operating system in Assembler this should be a walk in the park.


              only two letters away from being an asset

              M Offline
              M Offline
              Michael Eber
              wrote on last edited by
              #6

              Oh yes...another reason for doing this is to get the responses in all of the textboxes. Does that pass back in Viewstate as well? I dug through two obvious routes (control and Page) but nothing is there to access ViewState.

              N 1 Reply Last reply
              0
              • M Michael Eber

                Oh yes...another reason for doing this is to get the responses in all of the textboxes. Does that pass back in Viewstate as well? I dug through two obvious routes (control and Page) but nothing is there to access ViewState.

                N Offline
                N Offline
                Not Active
                wrote on last edited by
                #7

                Maintaining a control's state between requests is the purpose of ViewState (besides bloating the page :)) http://msdn.microsoft.com/en-us/library/ms972976.aspx[^]


                only two letters away from being an asset

                M 1 Reply Last reply
                0
                • N Not Active

                  Maintaining a control's state between requests is the purpose of ViewState (besides bloating the page :)) http://msdn.microsoft.com/en-us/library/ms972976.aspx[^]


                  only two letters away from being an asset

                  M Offline
                  M Offline
                  Michael Eber
                  wrote on last edited by
                  #8

                  Thank you for a usable answer. So it seems that the viewstate is updated prior to reaching my method ... that adds the new control. So it appears that for the webpage if I instantiate the viewstate update method after binding, then the control should show properly on the outbound process.

                  N 1 Reply Last reply
                  0
                  • M Michael Eber

                    Thank you for a usable answer. So it seems that the viewstate is updated prior to reaching my method ... that adds the new control. So it appears that for the webpage if I instantiate the viewstate update method after binding, then the control should show properly on the outbound process.

                    N Offline
                    N Offline
                    Not Active
                    wrote on last edited by
                    #9

                    A true professional would have been able to research this for themself


                    only two letters away from being an asset

                    M 1 Reply Last reply
                    0
                    • N Not Active

                      A true professional would have been able to research this for themself


                      only two letters away from being an asset

                      M Offline
                      M Offline
                      Michael Eber
                      wrote on last edited by
                      #10

                      Ahhh yes, you are two letters short of an asset.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups