Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 February 3rd, 2005, 09:51 AM
Registered User
Join Date: Feb 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unique Control IDs inside a loop using a varible

I'm trying to loop through a recordset and display the entires. No Problem.

Each entry has boolean, which corresponds to a checkbox. No Problem

Now after a user changes the checkboxes and a final update function is called I need to see which chekboxes have been changed and update the SQL data accordingly. Sounds easy enough.

So I should give each checkbox a unique name, since I'm inside a loop this SHOULD be a no-brainer. however I can't seem to use variables in the ID paramater of an ASP:Checkbox???

Old February 3rd, 2005, 10:07 AM
Friend of Wrox
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel

For each record you would be having a unique id in the table right? Add that as an ID to checkbox which creating. When user submits now you get the ID's of those checkbox which were clicked and update the DB accordingly.

Best Regards

Old February 3rd, 2005, 10:44 AM
Registered User
Join Date: Feb 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Yes each record has an ID in the table, and it's passed to the page.

However when I try to reference the entry ID to use as a control ID:

<asp:checkbox runat="server" ID=<%=SurveyRow["ID"] %> />

The error "Server tags cannot contain <% ... %> constructs" is returned. So What if I tried to set a varible "e" then use it:

    foreach(DataRow SurveyRow in Table)
        string e = SurveyRow["ID"];
 <asp:checkbox runat="server" ID=<%=SurveyRow["PkSurveyID"] %> />

Is there a way to reference "e" or???

Thanks Josh!

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Generate Unique values for IDs mphare XSLT 7 November 6th, 2008 12:20 PM
Control IDs in content pages LMIILM BOOK: Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages ISBN: 978-0-470-12448-2 1 December 8th, 2007 06:30 AM
Ints or Unique IDs? pettrer ASP.NET 2.0 Basics 3 June 5th, 2006 08:28 PM
Pass variables from array inside a loop dustygn PHP How-To 2 May 3rd, 2006 05:35 PM
unique login names and incremental user IDs krstofer Classic ASP Basics 8 March 11th, 2004 10:55 AM

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