If I have the following ASP.NET code (it\'s not complete - obviously there\'s a lot missing, but none of it matters):
Just set the datasource of the gridview to your object.
MyGridView.DataSource = myList
MyGridView.DataBind()
Here's a very similiar post:
Binding a method that returns List<employee> to a gridview
Looks like you are using a list in vb.net. Remember lists can hold integers, strings, dates, objects (these include user defined types (your object)). So you can bind a gridview to a list object by setting the datasource property to your list.
In the above example, myList, might hold a ton of employee objects, etc. So assign it to the datasource and .DataBind()
and voila a gridview with each row containing your object.
First remember any binding controls like GridView
, DropdownList
e.t.c bind to public properties, so first make your public members to public properties.
Then create objects of MyObject class and add them to your List<MyObject>
object
Finally you can persist this list object by saving it in Session
or ViewState
to maintain it after postbacks.
I hope you can do it now!!! you can ask for more help if neccessary.
You can do something like
My Label: <asp:Label id="myLabel" runat="server" Text='<%# Eval("MyTextBoxString") %>' />
in the markup and similar stuff for your textbox.
GridView1.DataSource = MyListOfObjects
GridView1.DataBind()