Good people i appologize in advance for my basic english. My problem is as follows I've place a gridview inside an accordion, inside another accordion. Eachone asociated to an objectdatasource. Now, each objectdatasource have an onselecting event for writing a e.InputParameters. The problem is that one of the parameters i want to write is in the dataitem of the item that contains the objectdatasource.
The args of the obselected function are: ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs
The firstone is a ObjectDataSourceView wich has not a namingcontainer. And i can't get any reference of de dataitem from the ObjectDataSourceSelectingEventArgs.
So, my question here is how can y get the reference of the objectdatasource, the item who containit or the dataitem asociated to that particular item into my "onselecting" function.
thanks in advance.
The vb is
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
the asp is
<%@ 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>
after lot's of trying i didn't get the reference to the dataobject so i pass the dataitem in filter expresion and makeit blank at the end of onselecting function.
The vb is
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", Trim(dsv.FilterExpression))
e.InputParameters("param") = parameters
dsv.FilterExpression = ""
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", Trim(dsv.FilterExpression))
e.InputParameters("param") = parameters
dsv.FilterExpression = ""
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
and the aspx is
<%@ 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: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" FilterExpression='<%# Container.DataItem("DOCNUMBR") %>'
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" FilterExpression='<%# Container.DataItem("CUSTNMBR") %>'
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>
</div>
</form>
</body>
</html>