문제

If I want to set both gridview.datasource and gridview.datamember, which one I should set first? Is there any standard order about this? Thank you!

도움이 되었습니까?

해결책

I would prefer to set gridview.datasource first and then only gridview.datamember because you do not need to set gridview.datamember property when binding to a data source that contains a single list or table.

다른 팁

Usually I set the datamember first. That way, when you set the datasource, it will refresh the grid using the datamember info. (If the datasource is a dataset, the datamember would be a table. If you set the datasource first and then the datamember, the datagrid will stay empty until explicitly refreshed.)

I do the same with all databound controls. For listboxes, I set the displaymember and valuemember first and then the datasource. The listbox then automatically has the proper info displayed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top