G
Gary Wardell
Hi,
MSDN says that I can use DataSource properety to bind to "Any object that
implements the IList interface".
How is this done? I can't seem to find any good examples for doing it all
by hand. (Most show doing it from a database with a DataTable)
I can get it to work in C#.
I've tried using a OrderedDictionary.
If throws this exception:
DetailsView with id 'DVRecord' did not have any properties or attributes
from which to generate fields. Ensure that your data source has content.
This is the code:
OrderedDictionary NVP = new OrderedDictionary();
NVP.Add("Company", "My, Inc.");
NVP.Add("Contact", "Me");
NVP.Add("City", "My City");
NVP.Add("ZipCode", "99999");
DVRecord.DataSource = NVP;
DVRecord.DataBind();
This is the form
<asp
etailsView ID="DVRecord" runat="server"
CssClass="DetailsViewStyle"
DefaultMode="Edit"
AutoGenerateRows="False"
AutoGenerateEditButton="False"
AutoGenerateDeleteButton="False"
AutoGenerateInsertButton="False"
OnPreRender="DVRecord_PreRender"
OnModeChanging="DVRecord_ModeChanging"
OnItemUpdating="DVRecord_ItemUpdating">
<FieldHeaderStyle CssClass="FieldHeader" />
<RowStyle CssClass="RowStyle" />
<EditRowStyle CssClass="EditRow" />
<AlternatingRowStyle cssClass="AlternateRowStyle" />
<CommandRowStyle CssClass="CommandRowStyle" />
<Fields>
<asp:BoundField DataField="Company" HeaderText="Company Names" />
<asp:BoundField DataField="Contact" HeaderText="Contact Names" />
<asp:BoundField DataField="City" HeaderText="City Names" />
<asp:BoundField DataField="ZipCode" HeaderText="Zip Codes" />
</Fields>
</asp
etailsView>
MSDN says that I can use DataSource properety to bind to "Any object that
implements the IList interface".
How is this done? I can't seem to find any good examples for doing it all
by hand. (Most show doing it from a database with a DataTable)
I can get it to work in C#.
I've tried using a OrderedDictionary.
If throws this exception:
DetailsView with id 'DVRecord' did not have any properties or attributes
from which to generate fields. Ensure that your data source has content.
This is the code:
OrderedDictionary NVP = new OrderedDictionary();
NVP.Add("Company", "My, Inc.");
NVP.Add("Contact", "Me");
NVP.Add("City", "My City");
NVP.Add("ZipCode", "99999");
DVRecord.DataSource = NVP;
DVRecord.DataBind();
This is the form
<asp
CssClass="DetailsViewStyle"
DefaultMode="Edit"
AutoGenerateRows="False"
AutoGenerateEditButton="False"
AutoGenerateDeleteButton="False"
AutoGenerateInsertButton="False"
OnPreRender="DVRecord_PreRender"
OnModeChanging="DVRecord_ModeChanging"
OnItemUpdating="DVRecord_ItemUpdating">
<FieldHeaderStyle CssClass="FieldHeader" />
<RowStyle CssClass="RowStyle" />
<EditRowStyle CssClass="EditRow" />
<AlternatingRowStyle cssClass="AlternateRowStyle" />
<CommandRowStyle CssClass="CommandRowStyle" />
<Fields>
<asp:BoundField DataField="Company" HeaderText="Company Names" />
<asp:BoundField DataField="Contact" HeaderText="Contact Names" />
<asp:BoundField DataField="City" HeaderText="City Names" />
<asp:BoundField DataField="ZipCode" HeaderText="Zip Codes" />
</Fields>
</asp