How to fill UpdatePanel in Repeater in ASPX (not for code)?

I have a relayer that displays a list of items (in a table / table view). When the user clicks on an element, I show an UpdatePanel in that element with additional information related to the element (similar to Accordion Control). I know how to populate an encoded UpdatePanel (I pass the ID of the selected item in the Repeater control as the CommandArgument, get more information for that ID, and customize the text boxes of the active UpdatePanel controls). But I'm wondering if I can configure the binding directly in ASPX (instead of code). When I used the syntax <%= %>

to assign the text fields of the UpdatePanel control to page property values ​​eg.<%= Comment %>

, it kind of worked, but it changed the fields of all UpdatePanels in the relay. Is there a way to bind the active UpdatePanel to the current values ​​and leave the unchanged UpdatePanels unchanged?

+1


source to share


2 answers


Do you want to display a container that displays additional information? Is there any other activity in the drawer that requires it to be an update panel?

<asp:repeater>
   <itemtemplate>
      <%# Eval("Name") %> <%# Eval("LastName") %><br />
      <span onclick="$get('<%# Eval("Id") %>')">View Age</span>
      <div id="<%# Eval("Id")%>" style="display:none;">
          Age: <%# Eval("Age") %>
      </div>
   <itemtemplate>
</asp:repeater>

      



I think that's correct, some syntax might be a bit (typing without intellisense). Will this work? I used ID as a unique identifier for the div id and onclick command. You can also use jquery, asp: controls, or whatever you need.

+1


source


The easiest way is to embed the FormView inside the update bar. Then the only thing you need to do in the code is to get additional information, assign it to the FormView.DataSource and call FormView.DataBind (). Everything in the FormView will use the syntax <% # Eval ("SomeColumn")%>. You will probably need to use FindControl () to get the link to the FormView. I would type in the code for you, but I will save you a few headaches on the road and say DON'T.

The refresh panel is the most inefficient way to do any ajax stuff. The only way to get everything to properly connect to this repeater and server code is to either have a giant viewfinder or retry the repeater on page load. You are making a request that could be 300ms into something that will take a second ... or longer! Get familiar with a good ajax map and don't be afraid to write real html. At the very least, use a web service that loads custom controls with your markup.



I know the refresh panel is simple and built in. It may even be adequate to what you are doing, but you must resist. You will be glad you did.

+1


source







All Articles