I was working on an
Imports System.ComponentModel
' Adding the DataObjectAttribute tells ObjectDataSource
' consumers this is a data source class
<DataObject(True)> _
Public Class MyServiceHelper
<DataObjectMethod(DataObjectMethodType.Select)> _
Public Function GetDivisions() As MySvc.Division()
Dim ps As New MySvc.MyServicePort
Dim psReq As New MySvc.GetDivisionsRequest
GetDivisions = ps.GetDivisions(psReq)
End Function
<DataObjectMethod(DataObjectMethodType.Select)> _
Public Function GetStaffByDivision(ByVal divName As String) As MySvc.Staff()
Dim ps As New MySvc.MyServicePort
Dim psReq As New MySvc.GetStaffRequest
Dim ss As New MySvc.StaffSearch
ss.DivisionDescription = divName
psReq.SearchInformation = ss
GetStaffByDivision = ps.GetStaff(psReq)
End Function
End Class
After creating the helper, this is all the code that was necessary to have two
Partial Class MasterDetail
Inherits System.Web.UI.Page
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
GridView2.Visible = True
GridView2.DataBind()
End Sub
Protected Sub ObjectDataSource2_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles ObjectDataSource2.Selecting
e.InputParameters("divName") = GridView1.DataKeys(GridView1.SelectedIndex).Value.ToString()
End Sub
Protected Sub GridView1_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PageIndexChanged
GridView1.SelectedIndex = -1
GridView2.Visible = False
End Sub
End Class
Thanks to Matt Berseth for his excellent post about AJAX GridViews, detailsView and ModalPopup.
No comments:
Post a Comment