开发者

IEnumerable Collection Binding to DetailsView control

I have a DetailsView control which gets data from a IEnumerable custom class. But I can't get updated values from the control so I can process to update 开发者_如何学运维them manually in the database. How can I do that?

Regads,

Gustavo


I suspect it can't work with an IEnumerable... The DetailsView probably needs to be able to access the data source by index (or at least a way to access a specific item of the data source), so I think the source has to implement IList. But I can't find anything about it in the documentation, so that's just a guess...


It seems like some added clarification might be useful here, but some notes:

  • the DetailsView can work with an IEnumerable source (assuming you're setting DataSource to the enumerable), but it'll bind to the first item fetched from the source.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.detailsview.aspx#binding_to_data

  • since it sounds like you're not binding to a data source, you'll need to hook up to an event (ItemUpdated in this case, I'd think) and then do the database update yourself

IMHO, if you can switch to binding against a 'real' data source life will be easier since you can let DetailsView do the heavy lifting for you, but if not, hopefully ItemUpdated will work for you :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜