How do I bind an ASP.NET FormView to a single record?

前端 未结 1 813

The whole purpose of the ASP.NET FormView control is to display a single record at a time. So how do I bind it to a single record? It complains that

D

相关标签:
1条回答
  • 2021-01-03 20:03

    As the error message says, the DataSource object must implement IListSource, IEnumerable or IDataSource to work.

    If you have an object av type A which do not implement one of the mentioned interfaces then you could as you say wrap your object in a list:

    C#

    var myDataSource = new List<A> {myObject};
    

    VB.NET

    Dim myDataSource As List(Of A)(myObject)
    
    0 讨论(0)
提交回复
热议问题