473,657 Members | 2,587 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB-WEB: Difficulties with ItemTemplate CheckBox ID

3 New Member
I am looking to do something like this to assign a unique ID to each checkbox in a gridview:

Expand|Select|Wrap|Line Numbers
  1. <asp:TemplateField Visible="False" HeaderStyle-CssClass="SpreadSheetHeader" ItemStyle-CssClass="SpreadSheetCell" ShowHeader="True" HeaderText="Add to Cart / Qty" >
  2.                         <ItemTemplate>
  3.                             Add?<asp:CheckBox ID='<%# Eval("DFNumber") %>' CssClass="chkOrder" runat="Server" />
  4.                             Qty:<asp:TextBox CssClass="txtBoxQuantity" ID="txtQuantity" runat="server"></asp:TextBox>
  5.                         </ItemTemplate>
  6.                     </asp:TemplateField>  
But I get the error message 'server tag is not well-former'. Is it possible to do it like this? If not, what would be a good way to assign a unique ID to a checkbox control in an item template?
Jul 28 '08 #1
1 1165
Frinavale
9,735 Recognized Expert Moderator Expert
I remember attempting to do the same thing that you are trying to do. I discovered that it isn't possible..and at one point had a good reason as to why this is but can't remember it off the top of my head.

Because the controls are dynamically given an ID anyways, why don't you just give the CheckBox an ID like "ChkboxAdd" , and include a hidden column called something like "DFNumber" that will keep track of what DFNumber you are "adding".

EG
Expand|Select|Wrap|Line Numbers
  1.       <asp:TemplateField Visible="False" HeaderStyle-CssClass="SpreadSheetHeader" ItemStyle-CssClass="SpreadSheetCell" ShowHeader="True" HeaderText="Add to Cart / Qty" >
  2.                               <ItemTemplate>
  3.                                   Add?<asp:CheckBox ID='ChkboxAdd' CssClass="chkOrder" runat="Server" />
  4.                                    Qty:<asp:TextBox CssClass="txtBoxQuantity" ID="txtQuantity" runat="server"></asp:TextBox>
  5.                               </ItemTemplate>
  6.                           </asp:TemplateField>
  7.                           <asp:BoundField Header="DFNumber" DataField="DFNumber ">
  8.                            <ItemStyle CssClass="noShow" width="0px">
  9.                            <HeaderStyle CssClass="noShow" width="0px">
  10.                           </asp:BoundField>
  11.  
Then in your code that does "stuff" loop through the rows in the gridview, grab the checkbox check value and the DFNumber for that row....and do your processing on that:

Expand|Select|Wrap|Line Numbers
  1. For Each dr In MyGridView.Rows
  2.        Dim chkBox as CheckBox=Ctype(dr.FindControl("ChkboxAdd"),Checkbox)
  3.        If chkbox.checked = true then 
  4. 'Here retrieve the DFNumber for the row that has been "checked".
  5.        End If
Jul 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

16
486
by: Terry | last post by:
Hi, I need some feedback. We are converting to .Net and we are trying to decide on whether to use VB.net or C#.net. As far as our current systems, they will probably be rewritten in ASP.Net. I have looked into both and I don't see anything that would scream out to use one or the other. So at this point, it is still a toss up. However, I want to look at the two languages from a different perspective. That is from a career point of view....
13
5146
by: Arsalan | last post by:
Is there any advantage in C# over VB.NET ? Or the difference is only syntax ? Can anything done in C# which cannot be done in VB.NET?
72
3442
by: Robin Tucker | last post by:
I need to find some documents/research for my manager about VB.NET v C# use. I've noticed that there are many more people using C# than VB.NET, that there seem to be more job vacancies specifying C# and projects written with it. I would basically like any links you might have to articles with non-anecdotal evidence for usage patterns, if there are any. Thanks,
28
2436
by: Andy | last post by:
Any good resources regarding benefitis by using C3 over VB? /Andy
12
1650
by: Leo Muller | last post by:
I always thought that moving from VB.NET to C# would be very easy. Even though so far it hasn't been hard, there are some annoying things, that may have to do with my visual studio settings. - When I type "system." the intellisense doesn't comlete this, only if I write it with a capital S, rather annoying... - is the type "string" or "String", both get excepted, but only "string" gets marked in blue, while all examples use "String" -...
16
2588
by: Ben Hannon | last post by:
Hi, I'm writting a COM Class in VB.NET to be used in a VB6 project (Tired of the VB6 hassles with cloning and serializing an object). All my classes I need cloneable/serializable are now in a VB.NET class that exposes those objects to COM perfectly. However I ran into a problem because some of these objects requires a Collection. When I compile this project with the VB.NET Collection exposed for a property, I get a compile time error...
182
7491
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
25
1815
by: Sharrukin Amiri | last post by:
Hello, I am using VB 6.0 for many years. Everytime I needed to build software applications, I just opened VB 6.0 and started coding. I am now looking VB.NET Express Edition and I find I can no longer do this very easily. I find that there is too much copy and paste of code in order to get an app running. I also find it slow. Is it me or I am missing something? Here is a sample of my coding which you could find at: ...
2
1684
by: D H | last post by:
Hi, Hi, I was looking for your opinion on VB.NET - its long-term prospects, etc. Sorry this is vague, but it's not meant to be a troll. It's a pro-VB.NET post actually. I haven't used VB or VB.NET really, but I have used Realbasic (a vb clone), Java, C#, C, and Python. I work in education, and I'd like something that is easy enough for teachers and students to use to develop real, usable applications, not just to learn programming for...
0
8306
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.