Hi I have a List which returns an array of \"Question\". My question is how can I bind this to a grid view? When I try to call Question.Ordinal I get that it does not exist in
Just set it directly to Ordinal, as the first examples in the post you just linked to:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="ID" DataField="CustId" />
<asp:BoundField HeaderText="Name" DataField="Name" />
<asp:BoundField HeaderText="City" DataField="City" />
</Columns>
</asp:GridView>
Say:
<asp:BoundField HeaderText="A Header" DataField="APropertyOfQuestion" />
you must be define the property member of class, as a propery ie
public string ProductName
{
get
{
return _productName;
}
set { }
}
Or VB
public property ProductName() as string set ..
get...
end property
important: Is Required defined get method
Try using the following syntax:
<%# ((MyObject)Container.DataItem).MyField %>