Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Thanks for creating this site - I expect to be visiting it often as I continue to try to grow my bag of tricks!..."

Geography

Where in the world do Tek-Tips members come from?

IDs the same in header and footer of GridView

tshad (Programmer)
25 Jun 12 14:04
I thought IDs had to be unique on a web page.

DotNet, adds a number at the end of IDs in a GridView row when the Grid is rendered so you will have unique IDs. But it doesn't do that for Headers and Footers (and the yet the page works fine).

If you have something like:

CODE

<asp:TemplateField ItemStyle-HorizontalAlign="Right" ItemStyle-VerticalAlign="Middle"
ItemStyle-Width="80px">
<HeaderTemplate>
<asp:Label ID="lblQuantityTotal" Text="" runat="server"></asp:Label>
</HeaderTemplate>
<FooterTemplate>
<asp:Label ID="lblQuantityTotal" runat="server"></asp:Label>
</FooterTemplate>
</asp:TemplateField>

The rendered code may be:
At the top of the Grid

CODE

</th><th align="center" scope="col" style="border-color:Black;border-width:2px;border-style:solid;font-weight:bold;">
<span id="MainPlaceHolder_mGridView_lblOrderQuantityTotal">291</span>

And at the bottom of the Grid

CODE

</td><td align="center" style="border-color:Black;border-width:2px;border-style:solid;font-weight:bold;">
<span id="MainPlaceHolder_mGridView_lblOrderQuantityTotal">291</span>

the ID's for the span are identical, how can that be???

Thanks,

Tom
Qik3Coder (Programmer)
26 Jun 12 10:58
They are in different child controls. This is why you have to do a "FindInHeader" or a "FindInFooter" to get at the controls.
The ids must be unique among controls IN THE SAME container.
In addition, if you look at the rendered HTML you will note that they get a different Client ID, that is basically the control tree down to the control.

Lodlaiden

You've got questions and source code. We want both!
There's a whole lot of Irish in that one.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close