善良な人々は、私の基本的な英語について事前に謝罪します。私の問題は次のとおりです。グリッドビューをアコーディオン内、別のアコーディオン内に配置しました。それぞれが objectdatasource に関連付けられています。現在、各 objectdatasource には、e.InputParameters を書き込むための onselecting イベントがあります。問題は、書き込みたいパラメーターの 1 つが objectdatasource を含む項目のデータ項目にあることです。
obselected 関数の引数は次のとおりです。ByVal 送信者 As オブジェクト、ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs
最初のものは、ネーミングコンテナを持たない ObjectDataSourceView です。そして、ObjectDataSourceSelectingEventArgs からデータ項目の参照を取得できません。
したがって、ここでの私の質問は、オブジェクトデータソース、それを含むアイテム、またはその特定のアイテムに関連付けられたデータアイテムの参照を「選択中」関数に取得する方法です。
前もって感謝します。
vb は
Imports System.Data.SqlClient
Public Class WebForm2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Page_lala(ByVal sender As Object, ByVal e As EventArgs) Handles Me.InitComplete
Accordion1.DataSourceID = ObjectDataSource1.UniqueID
Accordion1.DataBind()
End Sub
Protected Sub Accordion1_OnItemCommand(ByVal sender As Object, ByVal e As AjaxControlToolkit.AccordionCommandEventArgs) Handles Accordion1.ItemCommand
Dim Accordion2 As Control = e.Container.FindControl("Accordion2")
Dim objectDataSource As Control = e.Container.FindControl("ObjectDataSource2")
If Accordion1 IsNot Nothing And objectDataSource IsNot Nothing Then
AddHandler DirectCast(objectDataSource, ObjectDataSource).Selecting, AddressOf ObjectDataSource2_selecting
AddHandler DirectCast(Accordion2, AjaxControlToolkit.Accordion).ItemCommand, AddressOf Accordion2_ItemCommand
DirectCast(Accordion2, AjaxControlToolkit.Accordion).DataSourceID = DirectCast(objectDataSource, ObjectDataSource).ID
DirectCast(Accordion2, AjaxControlToolkit.Accordion).DataBind()
End If
End Sub
Protected Sub ObjectDataSource2_selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs)
Dim parameters(0) As SqlParameter
Dim dsv As ObjectDataSourceView = DirectCast(sender, ObjectDataSourceView)
parameters(0) = New SqlParameter("@cliente", "30697269610")
e.InputParameters("param") = parameters
End Sub
Protected Sub ObjectDataSource3_selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs)
Dim parameters(0) As SqlParameter
Dim dsv As ObjectDataSourceView = DirectCast(sender, ObjectDataSourceView)
parameters(0) = New SqlParameter("@documento", "FC0030-00040199")
e.InputParameters("param") = parameters
End Sub
Protected Sub Accordion2_ItemCommand(ByVal sender As Object, ByVal e As AjaxControlToolkit.AccordionCommandEventArgs) 'Handles Accordion2.ItemCommand
Dim gridview As Control = e.Container.FindControl("gridviewAplicaciones")
Dim objectDataSource As Control = e.Container.FindControl("ObjectDataSource3")
If gridview IsNot Nothing And objectDataSource IsNot Nothing Then
AddHandler DirectCast(objectDataSource, ObjectDataSource).Selecting, AddressOf ObjectDataSource3_selecting
DirectCast(gridview, GridView).DataSourceID = DirectCast(objectDataSource, ObjectDataSource).ID
DirectCast(gridview, GridView).DataBind()
End If
End Sub
End Class
ASPは
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm2.aspx.vb" Inherits="WebApplication4.WebForm2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ScriptManager ID="ScriptManager1" runat="server" >
</asp:ScriptManager>
<asp:Accordion id="Accordion1" runat="server"
SelectedIndex="-1" RequireOpenedPane="false" ClientIDMode="Static">
<HeaderTemplate><%# Container.DataItem("CUSTNMBR")%> / <%# Container.DataItem("CUSTNAME")%></HeaderTemplate>
<ContentTemplate>
<asp:LinkButton runat="server" ID="LinkButton1" Text="ver mas 1"></asp:LinkButton>
<asp:Accordion id="Accordion2" runat="server" OnItemCommand="Accordion2_ItemCommand"
SelectedIndex="-1" RequireOpenedPane="false">
<HeaderTemplate><%# Container.DataItem("DOCNUMBR")%></HeaderTemplate>
<ContentTemplate>
<asp:LinkButton runat="server" ID="LinkButton2" Text="Ver mas2"
></asp:LinkButton>
<asp:GridView runat="server" ID="gridviewAplicaciones" AutoGenerateColumns="true">
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource3" runat="server"
SelectMethod="ExecuteDataset" TypeName="WebApplication4.DbHelper">
<SelectParameters>
<asp:Parameter DefaultValue="multiconex_aplicaciones" Name="nombreSP"
Type="String" />
<asp:Parameter Name="param" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>
</ContentTemplate>
</asp:Accordion>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
SelectMethod="ExecuteDataset" TypeName="WebApplication4.DbHelper" >
<SelectParameters>
<asp:Parameter DefaultValue="multiconex_aging" Name="nombreSP"
Type="String" />
<asp:Parameter Name="param" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>
</ContentTemplate>
</asp:Accordion>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="ExecuteDataset" TypeName="WebApplication4.DbHelper">
<SelectParameters>
<asp:Parameter DefaultValue="multiconex_rm00101" Name="nombreSP"
Type="String" />
<asp:Parameter Name="param" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>