Dynamic array of controls - in a MultiView Control

Hey,

I am using the MultiView control to create a Wizard style web app. At some point in the Wizard I need the user to input 2 values which correspond to rows and columns. On the next step in the Wizard i proceed to create and put in a View rows*columns textboxes. Here is some of my code:

Global declaration:  public TextBox[] textBoxBarCodes;

Code to write the textboxes to the view:
 textBoxBarCodes = new TextBox[numRows * numCols];

        int k = 0;
        for (int j = 0; j < numRows; j++)
        {
            TableRow r = new TableRow();
            for (int i = 0; i < numCols; i++)
            {
                TableCell c = new TableCell();
                textBoxBarCodes[i] = new TextBox();
                textBoxBarCodes[i].ID = k.ToString();
                c.Controls.Add(textBoxBarCodes[i]);
                r.Cells.Add(c);
                ++k;
            }
            tableView1.Rows.Add(r);
        }

            this.View1.Controls.Add(tableBarCodes);

 

Now my problem is that I can't reference back to the array of textboxes.  I know that I should be recreating each time on page init, but I am unlcear how to do that in terms of the Wizard (i.e I only know how many textboxes I need after several initial postbacks).

 If someone could point me in the right direction that would be VERY much appreciated.

Begin22
 

0
begin22
4/22/2007 4:56:42 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

1 Replies
543 Views

Similar Articles

[PageSpeed] 7
Get it on Google Play
Get it on Apple App Store

Hi,

You can keep the value of numRows as well as numCols in Session, and recreate those textboxs according to the value upon the next request.

Page_Init()
{
 int numRows = 0;
 int numCols = 0;
 if(Session["row"] != null && Session["col"] != null)
 {
    numRows = (int)Session["row"];
    numCols = (int)Session["col"];
 }


textBoxBarCodes = new TextBox[numRows * numCols];

int k = 0;
for (int j = 0; j < numRows; j++)
{
TableRow r = new TableRow();
for (int i = 0; i < numCols; i++)
{
TableCell c = new TableCell();
textBoxBarCodes[i] = new TextBox();
textBoxBarCodes[i].ID = k.ToString();
c.Controls.Add(textBoxBarCodes[i]);
r.Cells.Add(c);
++k;
}
tableView1.Rows.Add(r);
}

this.View1.Controls.Add(tableBarCodes);

}

Hope this helps.
0
Raymond
4/26/2007 5:33:11 AM
Reply:

Similar Artilces:

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

controlling an object in a web control from the page the web control is placed in
I have created a web control in vb.net that has an image button and an image. when it loads the image button is visible and the image is not. I want to be able from the page which "includes" the web control to set the image button to invisible and the image to visible. When I tried this, the main page didn't recognise the image button or the image (both < asp: objects). help would be gratefully appreciated. oh yeah, it's inline code so any code behind stuff will just confuse me ;) Some code please.-- Justin Lovell...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Dynamic Slave Controls
I am working a solution to enhance slave controls. I have created a proof of concept based on the 2.04 code base that shows how to load slave controls without switching to the admin view. I have included a sample module that contains 3 view controls. Each control has a row of buttons that can be used to load one of the other 2 controls. (and no I am not using panels.) The default control has a drop down of other instances of the dynamic control that exist on the current tab. Using the module communicator you can raise an event from one control that tells another instance of the module what c...

HTML Controls vs Web Form Controls
Hi, I have a page with both controls (HTML and Web Form Controls). I am trying to use an html Calendar control and then get the date selected by the user and put into a Web form input field control. When I try to run this the HTML control cannot talk to the Web form control. Any ideas? Thanks. Can't you put some javascript in the HTML-control with which you assign the value to the ASP.NET Server control? Please post some code so I can help u. Kind Regards,ThaYoung1! Hi here is the Code. Also I added a web form text input control and an html text control and created a fu...

Dynamic Control problem in Web user control
hi friends, i am developing an web user control.   in that i require to add RADEditor control dynamically when the user press ADD button.   But i am unable to retain the control when the page is post back.   Can anybode send me the sample..   Note that it should be in an Web User Control  Just to make sure, Did you place the code addinthe control dynamically inside the "if (!IsPostback)" inside the page_load? santhoshonet: hi friends, i am developing an web user control.   in that i require to add RADEditor control dynamically when the...

Add .Net Control to Web Custom Control
 I want to add .NET Control (like: TextBox, Button...) to Web Custom Control.How i can do it? Alphavn That's called a composite control -- "Mark As Answer" if my reply helped you -- Hello Guys What gunteman said, that is one approach and in most cases the right one.But its also possible to add child controls to a Control thats inherit from WebControl itself. Be sure to implement INamingContainer to that inherited Control too, thats the important point of that approach.--Microsoft MVP - Visual Developer ASP / ASP.NET- http://www.aspnetzone.de/blogs/peterbuch...

Web form Controls vs HTML controls
Hi, can anyone explain me the difference between Web Form Controls and HTML controls? What is their usability and disadvantages? Can i write code behind HTML controls?    Thanx in advance. Yes, you just have add "runat=server", in your HTML control. The Web Server Control, have more funtionality that the HTML controls. With Web Server Control, you can work easy with Data. Too, you have controls as AdRotator, WebCalendar and more... : http://samples.gotdotnet.com/quickstart/MCP Sergio Tarrillo Here are the Recommendations from Microsoft ....when to use 1 over the other...

Use Web Control In a Web Control
Is this possible?I am working with an aspx page that consists of many different web controls.One of the web controls contains search criteria.  One of the criteria is a date range where I am trying to add a popup calendar --> which is another web controlCan I register the popupcaledar control on the questionaire control?  I have tried, but nothing seems to be registered.Any ideas will GREATLY help.Relax and have some Home Brew!Prosecute the Owner - Don't PERSECUTE the Breed!Breed Specific Legislation targets the WRONG end of the LEASH! Without seeing your code we can'...

web controls and web user control
i have a problem in a web form , I have a webform that contains a web user control which in turn contains a html input form ,the web control events don't fire up ,When I click button ,no effect ,I don't know what is the effect of the html form which is in the web user control on the web controls in the web form ?? can any one help me the web control event should be handle in the code behind page, is the event handler for the button you are clicking registered? You can try double clicking the button, should give you the default btn_click event handler in code behind. Also, make ...

Web resources about - Dynamic array of controls - in a MultiView Control - asp.net.web-forms

Multiview orthographic projection - Wikipedia, the free encyclopedia
These quadrant labels are the same as used in 2D planar geometry, as seen from infinitely far to the "left", taking H and V to be the X -axis ...

MultiView CalculatorHD Free on the App Store on iTunes
Get MultiView CalculatorHD Free on the App Store. See screenshots and ratings, and read customer reviews.

Samsung Galaxy S3 to get MultiView, Smart Rotation
Some of the Galaxy Note II's standout features are coming to Samsung's best-selling device with pending Android 4.1.2 update.

Samsung's MultiView MV900F begins shipping with 180-degree AMOLED display for $350
Shipping targets aren't set in stone, so we weren't terribly surprised to see Samsung miss its late-August goal for the new MultiView MV900F ...

Todd Ebert, CMO, MultiView: Articles - iMediaConnection.com
December 6 - 9, 2015 Scottsdale, Arizona Large and small agencies alike must be nimble in execution in order to meet their clients' desires for ...

MultiView Names B2B Marketing Expert Todd Ebert as Chief Marketing Officer
DALLAS, TX(Marketwired - Sep 10, 2015) - &#160;MultiView, the fearlessly creative provider of digital marketing solutions in the B2B space, today ...

Lensless multiview camera cleverer than Lytro and PureView combined
A lensless, focussing-free camera that can take photos from multiple angles simultaneously, building up either different perspectives of a scene ...

Samsung launches second 'multiview' camera
Samsung has launched the MV900F, a follow up to last year's Samsung MV800 . The most obvious feature of this camera is its flip-up screen, designed ...


OnLive’s MultiView spectating entices multiplayer and co-op gamers
Video game streaming service OnLive gets a three-window spectating feature called MultiView, and its competitive, cooperative, and multiplayer ...

Resources last updated: 12/1/2015 1:26:43 AM