如何从共享函数调用gridview

时间:2014-08-15 10:17:57

标签: asp.net vb.net

我有一个例程,我使用Javascript调用客户端。出于这个原因,它必须是一个webmethod因此它必须'共享'(C#中的静态)

<System.Web.Services.WebMethod()> _
Public Shared Sub LoadBewerkIndirecteKosten(_team As String, _year As Integer)
    Try
        '    dconnection = DatabaseConnection.Instance
        Dim con As New Connection

        Dim sql As String = ""
        sql = String.Format(" exec CSSSR_FEZ_Get_BewerkIndirecteKosten '{0}', {1} ", _team, _year)
        Dim dt As DataTable ' = New DataTable
        Dim ds As DataSet = con.QueryUnsecure(sql, Nothing, EDLQueryOptions.DataSet)

        dt = ds.Tables(0)
        SSR_IndirecteKosten.gvBewerkIndirecteKosten.DataSource = dt
        gvBewerkIndirecteKosten.DataBind()
    Catch ex As Exception
        log.Fatal(String.Format("Error in: {0}: {1}", "LoadBewerkIndirecteKosten", ex.Message))
    End Try
End Sub

在javascript(在我的aspx中)中,我将这个函数称为:

PageMethods.LoadBewerkIndirecteKosten('FEZ', 2014, OnSucceeded, OnFailed); 

通常这种结构工作得很好,只要不调用sreen组件,但在这种情况下,我运行一个存储过程,填充一个数据表,并希望将其数据绑定到gridview。

有谁知道怎么做?在此先感谢!!

0 个答案:

没有答案