Referencing a specific repeater item instance

I've been looking all over StackOverflow and Google for an answer to this question, but I haven't been able to find anything.

I have a C# based ASP webpage that uses a repeater control to list information about students returned via a SQL procedure. To populate the repeater, the web app I am working in uses a Student class with [DataMember] properties representing each field in a SQL query result row. From my understanding, each item in the repeater control contains a separate instance of the Student class, with each instance representing a row in the query results. First, please let me know if the repeater operates differently than I understand.

If my understanding is correct, however, I would like to know if there is any way to reference a student instance contained in the specific item of the repeater control. I looked at a few methods associated with the repeater object, including:

repeater.Items        //This gets a collection of objects
repeater.DataMember   //Gets the 'specific table to bind'
repeater.DataSource   //References the SQL query results

None of these seem to reference the SQL row/'Student' instance.

Is there something that I am missing or not understanding correctly? I have been pouring over the MSDN site for the repeater control as well, but I may not be understanding all the terminology, if there is a solution on the page. The MSDN repeater page I am using is http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater(v=vs.100).aspx.

Answers


The items are stored in the repeater.Items statement and you can cast the items to whatever type you are expecting:

var student = (Student)repeater.Items[3];

Need Your Help

What is the proper way to pass errors from classes to rendered html in python

python pylons mako

I'm performing all my form validation in a class, and would like to be able to get the errors from the class to the rendered html. One approach I was thinking about was to create a global variable...

cheesesquare app on v23 chrashes when dismissing snackbar

android material-design

cheesesquare is a demonstration app for material design.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.