Solved

UpdatePanel inside a GridView with AlternatingItemTemplate's (2)

Posted on 2011-03-06
4
946 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add a Condition in ASP Repeater 6 34
LINQ Select all records by MAX data syntax help 1 17
Need syntax help building hyperlink 2 25
How to repeat the data 4 17
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 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