 |
| ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.1 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
|
|
|
|

January 14th, 2004, 01:19 AM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
how to find datalist inside placeholder
On my page I have a table and in each cell of the table I have placeholder. I am readring from a database and each table in the database is represented by each placeholder of the table on my page. For example, on of the placeholder id is "xyz_P". there is a tabel in the database called "xyz". when loading the page, I am reading the looking for a record in each table of the database. so if xyz has the record I am looking for, then I will programatically create a Datalist called xyz_D inside the xyz_P Placeholder. then I load a template in the database and bind the data to the datalist.
now if the user clicks the submit button I am trying to read the form back to the database. I can say the following code:
PlaceHolder ph = (PlaceHolder)Page.FindControl("xyz_P");
and find it. but then I can't any control inside ph.
any idea why?
I simply need to find the datalist xyz_D and the checkboxes inside it. any idea how to read them back.
Thx
|
|

January 16th, 2004, 12:35 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
The placeholders on your pages exist in the markup in the aspx page. .net instanciates them based on that. When you add controls to a page at runtime, very strange things can happen. You won't necessarily be able to see those controls on a postback.
Why not just add the datalists to the placeholders in the markup so they are there and ready to use? You can disable/hide the ones you don't need if that is so desired.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

January 16th, 2004, 06:24 PM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
so after I check for the existence of the record in the database, if I don't find that, then I still need to draw those fields(checkboxes) in that placeholder, but the checkbox 'es will be not checked. Since you can't draw the datalist fields without databinding (as far as I know), I had the placeholder and then dynamically drawing the datalist (if record found) or loading a control (table with all the checkbox 'es) from a .ascx page in that placeholder.
I got it working(fortunately) so far. Still it would be nice to hear your opinion on this approach.
Thanks for your reply
|
|

January 17th, 2004, 01:05 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
What are these checkboxes for? I'm not quite understanding what they are for. And I'm not quite understanding what you mean about looking for a record, then if it's found, you are binding something to a datalist. Usually you bind a datalist to some kind of dataset object (dataset, datatable, datareader) that represents 1 or more fields and 0 or more rows.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

January 18th, 2004, 03:59 AM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
sorry for being vauge. This my story in short:
I have a database table name xyz. It has 5 columns of type yes/no and one column of type text and this is the Id field.
on pageload I read the table and check the id field with a id value that i got from previous page (passed on by cookie). If it find a record with that id, it reads it in reader and then bind it to the datalist. the itemtemplate of the datalist is bing loaded from a .ascx page with checkboxes representing those fields. In this case I am creating Datalist and placing it in the placeholder.
Now if it doesn't find any record then, it should still load the template but, in this case all of the checkboxes will be unchecked. This is for the id in the cookie. This way I am giving the user a option to create a record for this id in that table. In this case I am creating a Control and loading the seperate template (which doesn't have any databinging for each checkboxes ) and placing it in placeholder.
Hope this explains better then before. I have got it working. at this point I am just wondering if there was any better efficient way to design it. Specially at the part where I am creating and loading Datalist or Control in the placeholder.
Thnaks
|
|
 |