I have been searching online for the best way to populate databinder within a repeater. I have no luck in finding the best solution. The closest I got to was using datagrid that you can populate with a resultset from database. The data that I would like to display is from a csv file. It has 5 items in each row. Each of these items represent a field in the webpage. I have no problem getting the value from csv file. How do I populate strSource with the value from csv file? Do I use array, arraylist or anything? in .aspx.vb: RepeaterImages.DataSource = strSource in .aspx <asp:Repeater ID="RepeaterImages" runat="server"> <ItemTemplate> <asp:Textbox ID="txtTextbox1" runat="server" text='<%# DataBinder.Eval(Container.DataItem, "item1")%>' </asp:Textbox> <asp:Textbox ID="txtTextbox2" runat="server" text='<%# DataBinder.Eval(Container.DataItem, "item2")%>' </asp:Textbox> <asp:Textbox ID="txtTextbox3" runat="server" text='<%# DataBinder.Eval(Container.DataItem, "item3")%>' </asp:Textbox> <asp:Textbox ID="txtTextbox4" runat="server" text='<%# DataBinder.Eval(Container.DataItem, "item4")%>' </asp:Textbox> <asp:Textbox ID="txtTextbox5" runat="server" text='<%# DataBinder.Eval(Container.DataItem, "item5")%>' </asp:Textbox> </ItemTemplate> </asp:Repeater>
You need to do 2 things: 1. Set the DataSource property. This must be an object that implements the IEnumerable or IListSource interface, so it can be a Generic List, ArrayList or similar. If you can get your csv data into an ArrayList, then that should be OK. 2. Call the DataBind method for the Repeater to bind the control to the DataSource. So your code would look like: RepeaterImages.DataSource = myDataSource RepeaterImages.DataBind()
I'm not so hot with VB.Net as I use C#. However, you could try populating a DataTable with the data from your CSV file and then bind the DataTable object to the Repeater. Take a look at the answer to this question for an example: http://stackoverflow.com/questions/11118678/convert-csv-data-to-datatable-in-vb-net