Solved

UpdatePanel inside a GridView with AlternatingItemTemplate's (2)

Posted on 2011-03-06
4
948 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

759 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