Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Pass Parameter in Repeater Label?
in c# .net I have a label on a repeater.
I want to call a function in a label, but it needs to pass a parameter
<asp:Label ID="lblRPDecayActivity" runat="server" ReadOnly="true" CssClass="FormReadOnlyValue" Text='<%# CalculateDecayDays(ID) %>' />
How do I pass the ID to the CalculateDecayDays(ID) - the function takes an integer, which is the id field of the repeater.
2 Answers
- RatchetrLv 77 years agoFavorite Answer
So you have databoud the repeater to a datasource with an ID field of type integer then? (Just making sure I understand the question).
This should work then:
Text='<%# CalculateDecayDays( (int)Eval("ID") ) %>'
Eval should get the value of the property ID from the current row in the datasource. It returns Object, so you need the cast to int.
If that doesn't work, then I didn't understand what you are doing. Maybe post a little more code? What is your data source for the repeater?