DetailsView did not have any properties?

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:DetailsView 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:DetailsView>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top