Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Layout of dynamic controls in placeholder.

Status
Not open for further replies.

N3XuS

Programmer
Mar 1, 2002
339
BE
Been looking for this one for a while now, how to layout dynamiccally created controls. Found some C# sharp which looked like this
Code:
Form1.Controls.Add(
  new LiteralControl("\r\nWhat is your name?\r\n"));
TextBox TextBox1 = new TextBox();
...
Finally I got the picture lol, gotta actually put HTML in there using literals. So joy joy off to the workbench with that.
I ended up with something like this
Code:
            litLiteral.Text = "<tr><td>"
            Me.phParameters.Controls.Add(litLiteral)
            Me.phParameters.Controls.Add(lblParameter)
            litLiteral.Text = "</td><td>"
            Me.phParameters.Controls.Add(litLiteral)
            Me.phParameters.Controls.Add(txtParameter)
            litLiteral.Text = "</td><td>"
            Me.phParameters.Controls.Add(litLiteral)
            Me.phParameters.Controls.Add(chkParameter)
Problem is ... it's not adding the literals to the placeholder at all :'( Am I doing this all wrong, are there easyer ways or ?

Many thx
 
Just shoot me now ... .NET drives me absolutely nuts ... well changed the name of the literal from litLiteral to litHello and it worked ...
 
Lol ok I get what the problem is :p only the last value I give is added ... aight that was dumb :p Still ... counterintuitive should be in ASP.net's name somewhere
 
counterintuitive should be in ASP.net's name somewhere
Why? It seems to me that you are simply using the wrong control for the job so that's bound to make life harder.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Well actually, what I do is get parameters from a location out of the database, you gotta check the checkbox to indicate you want to use the parameter and enter a value in the textbox. Doing that with a datagrid would make it even harder for me as I downright hate those things. And a repeater would leave me with the crappy thing that I can't switch to design when I want to, with the binding thingy... plus would still need to find the controls ... would end up about the same but more anoying lol. Unless I can add textboxes into the checkboxlist control I don't see how it can be easyer :)
 
And a repeater would leave me with the crappy thing that I can't switch to design when I want to
How does that make a difference? The only way you actually see the correct output is to actually run the application in a browser anyway so that kind of makes the design window redundant (personally, I never use it at all).

The repeater is much more suited to your situation as:

1) You are currently using tables incorrectly. They are designed to show tabular data, not for page layour which is what you are doing.
2) The repeater is designed to do exactly what you want. You want a CheckBox and a TextBox repeated for entry in a database.

Using a combination of the repeater and CSS to layout the controls, you can achieve a much neater and semantically correct page.



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top