将sql数据库表绑定到银光数据网格

时间:2010-07-29 10:16:23

标签: silverlight

如何在不使用linq的情况下将sql数据库表绑定到silverlight数据网格?

怎么办呢?

1 个答案:

答案 0 :(得分:0)

您无法直接将sql datatable绑定到silverlight数据表。

我这样做了:

1)我在webservice中创建了业务对象:

Public Structure DCDData
        Dim ProductDescription As String
        Dim Yield As String
        Dim Pair As String
        Dim Tenor As String
        Dim StrikePoints As String
End Structure

2)返回业务对象List的Writtern webservice方法


 Dim list As New List(Of DCDData)
 Dim dtTable As New DataTable("DataTable1")

Call objDCD_Product_Dashboard_DB_Functions.DB_Get_DCDData(strCcyPair, strTenor, dtTable)

For i As Integer = 0 To dtTable.Rows.Count - 1 Dim objDcdData As New DCDData objDcdData.ProductDescription = dtTable.Rows(i).Item("Product_Description").ToString objDcdData.Yield = dtTable.Rows(i).Item("Yield").ToString objDcdData.Pair = dtTable.Rows(i).Item("Pair").ToString objDcdData.Tenor = dtTable.Rows(i).Item("Tenor").ToString objDcdData.StrikePoints = dtTable.Rows(i).Item("Strike Points").ToString list.Add(objDcdData) Next

Return list

3)在silverlight页面中将datagrid绑定到对象列表