[英]How to display one row of data grid in ASP.NET c# using WCF
我正在使用WCF在Silverlight應用程序中工作。 我想在數據網格中顯示數據庫中的特定行。
我發現e.result但是這將顯示數據庫的全部內容。
下面是我的代碼:
public TrainingBatchesUsersResults(int TraineeID)//, int TrainingProgramID, int >ReadyContainerID, int TrainingBatch, int ReadyContainerItemID)
{
InitializeComponent();
XraySimulatorWCFServices.XraySimulatorServiceClient XrayClient =new XraySimulatorWCFServices.XraySimulatorServiceClient();
XrayClient.GetTrainingBatchesUsersResultsCompleted += new EventHandler<
XraySimulatorWCFServices.GetTrainingBatchesUsersResultsCompletedEventArgs>(DisplayTrainingBatchesUsersResults);
XrayClient.GetTrainingBatchesUsersResultsAsync(TraineeID);
LayoutRoot.UpdateLayout();
}
private void DisplayTrainingBatchesUsersResults(object sender, XraySimulatorWCFServices.GetTrainingBatchesUsersResultsCompletedEventArgs e)
{
dgvResult.ItemsSource = e.Result;
dgvResult.Visibility = System.Windows.Visibility.Visible;
}
只需將ItemsSource
設置為要顯示的單行,而不是整個結果集合即可。 例如dgvResult.ItemsSource=e.Result.FirstOrDefault(x=>x.Id==theIdYouWantToShow)
但是,您真正想要的是在整個鏈上進行此操作,以便僅返回所需的單行,而不是返回整個表並減少客戶端上的設置。 您的呼叫XrayClient.GetTrainingBatchesUsersResultsAsync(TraineeID);
大概是在返回所有行,為什么不擁有一個只返回您感興趣的單個結果的新方法呢?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.