Link to home
Start Free TrialLog in
Avatar of Christian de Bellefeuille
Christian de BellefeuilleFlag for Canada

asked on

UpdatePanel inside a GridView with AlternatingItemTemplate's (2)

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.
ASKER CERTIFIED SOLUTION
Avatar of Kamal Khaleefa
Kamal Khaleefa
Flag of Kuwait image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Christian de Bellefeuille

ASKER

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
no more comment been added... so i guess that i have no other choice to do this annoying patch.
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" />