Solved

UpdatePanel inside a GridView with AlternatingItemTemplate's (2)

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
advertisement module in core php 4 88
Convert string to date 3 40
Check if number is currency 15 29
dynamic menu in asp.net c# 11 29
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 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

20 Experts available now in Live!

Get 1:1 Help Now