DetailsView did not have any properties?

Discussion in 'ASP .Net Web Controls' started by Gary Wardell, Jul 18, 2008.

  1. Gary Wardell

    Gary Wardell Guest

    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>
    Gary Wardell, Jul 18, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page