Binding a Repeater control to a jagged array

Binding a Repeater control to a jagged array

Binding the Repeater in the code-behind is done just like with any other binding operation. Suppose we have a jagged array named myJagged (which we didn’t initialize with values in this example) and a Repeater named myRepeater:

// Initialize the string array
string[][] myJagged; // Remember to initialize the array with values
myRepeater.DataSource = GroupList;

While binding the array to the repeater is done the same way as when binding to a DataReader, displaying the values inside the array on the webpage is different than when you are binding to a DataReader. To display a value of the array in the webpage, use <%#DataBinder.Eval(Container, “DataItem[0]”)%> where 0 is the index of the array value:

<asp:repeater id="myRepeater" runat="server">
      <li><%#DataBinder.Eval(Container, "DataItem[0]")%> <%#DataBinder.Eval(Container, "DataItem[1]")%></li>
Nathan Pakovskie is an esteemed senior developer and educator in the tech community, best known for his contributions to With a passion for coding and a knack for simplifying complex tech concepts, Nathan has authored several popular tutorials on C# programming, ranging from basic operations to advanced coding techniques. His articles, often characterized by clarity and precision, serve as invaluable resources for both novice and experienced programmers. Beyond his technical expertise, Nathan is an advocate for continuous learning and enjoys exploring emerging technologies in AI and software development. When he’s not coding or writing, Nathan engages in mentoring upcoming developers, emphasizing the importance of both technical skills and creative problem-solving in the ever-evolving world of technology. Specialties: C# Programming, Technical Writing, Software Development, AI Technologies, Educational Outreach

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top