Pass new parameter to function called in OnItemDataBound event
-
I have a question regarding the OnItemDataBound event and I'm hoping someone can help me out. Right now I have and the function definition is: protected void FillRepeater(object sender, RepeaterItemEventArgs e) What I'd like to do is pass a parameter to the function like this: But I'm not sure this is possible? I've edited my function definition to protected void FillRepeater(object sender, RepeaterItemEventArgs e, int num) but I'm not sure how to edit the markup to pass the first 2 expected parameters?
-
Answer:
You can't modify the signature of ASP.NET server control event handlers, but I suspect that you're trying to either pass the index of the current item or grab a property off of the current item. Here's a few lines that might help you out if that's your aim: protected void FillRepeater(object sender, RepeaterItemEventArgs e) { // this will get the object that the current repeater item is bound to YourItemType item = e.Item.DataItem as YourItemType; // this will get the index of the current repeater item var collection = repeater.DataSource as List<YourItemType>; int itemIndex = collection.IndexOf(e.Item.DataItem as YourItemType); }
Felipe Kettle at Stack Overflow Visit the source
Related Q & A:
- how to estimate the phase parameter of a complex function?Best solution by Mathematics
- How to pass multiple parameters in a single Ajax function?Best solution by stackoverflow.com
- How to pass parameter in wordpress url?Best solution by Stack Overflow
- How to call a function with parameter in a bash script?Best solution by tldp.org
- How can I pass global variables into a function?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.