Solved

UpdatePanel inside a GridView with AlternatingItemTemplate's (2)

Posted on 2011-03-06
4
938 Views
Last Modified: 2012-05-11

Read Carefuly Please

Before anyone answer this question, i would like to mention that what is mentionned here WORK PERFECTLY without the Ajax UpdatePanel.  Keep that in mind if you are going to reply please because i need an answer to this question.  Thank you.

Here's my question

I've a GridView object which is using AlternatingItemTemplate (and ItemTemplate of course).  I can have a button for example in both items, with the same name, and everything is just fine.  Without an UpdatePanel, VS2010 doesn't bug me with a duplicate name.

But as soon as i try to put an UpdatePanel in the ItemTemplate and AlternatingItemTemplate, it start to tell me that my button is already defined.

Since i can't put an UpdatePanel right bellow a TemplateField, it mean that i got to put the whole GridView inside an UpdatePanel, and not only the item that i wish to update.

Is there anyone who got this same problem, and found a solution to that?  

I think it's overkill to update the whole grid, there must be something i don't know how to do.

Thanks for your help.
0
Comment
Question by:cdebel
  • 3
4 Comments
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 500 total points
ID: 35053535
why you dont change the button name and have two names
and inside their event put the same code
0
 
LVL 10

Author Comment

by:cdebel
ID: 35056488
That's what i call a "Patch".  It was what i was going to do to make it work if i really didn't find any good solution.    I try to avoid to have duplicate code.

I thought i just missed something, and that there was a reason for not letting me having 2 items with the same name.

i'll let this case opened for a bit today, but if you got 147K points in ASP.NET, the chances are that there's no other workarround.  Thanks for your help
0
 
LVL 10

Author Closing Comment

by:cdebel
ID: 35069519
no more comment been added... so i guess that i have no other choice to do this annoying patch.
0
 
LVL 10

Author Comment

by:cdebel
ID: 35089856
Here's what i'm doing.  I've defined almost the same button like this.  Both are calling ToggleSendMessage.  The only difference is the ID, where i added "_Alt" at the end of the ID for the AlternateItem.

So in ToggleSendMessage, i check for the last 4 characters of the ID to see if it's "_ALT" or not.  This way, i don't have to read an hidden field to know if i'm in alternateItem or just regular item.

<asp:ImageButton ID="btnToggleSendMessage_Alt" runat="server" ImageUrl="_Alt" CommandName='<%#Eval("UserName") %>'  CommandArgument='<%#Eval("bNoteFromTherapist") %>' OnClick="ToggleSendMessage" />
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
A short film showing how OnPage and Connectwise integration works.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now