
10/08/2008, 23:11
|
 | | | Fecha de Ingreso: febrero-2003 Ubicación: Sarasota FL
Mensajes: 147
Antigüedad: 22 años, 1 mes Puntos: 0 | |
Respuesta: Como pasar varias variables por sesion estimado lualhulo, por que no usas controles anidados en tus combos?
Revisa este ejemplo, creo que es lo que deberias implementar.
Saludos
formulario
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="frmControlAnidados.aspx.vb" Inherits="frmControlAnidados" %>
<!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>Página sin título</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 235px">
<tr>
<td>
</td>
<td>
<strong>Clase de Controles Anidados</strong></td>
<td style="width: 7px">
</td>
</tr>
<tr>
<td>
</td>
<td style="text-align: center">
<asp:DropDownList ID="DD_Region" runat="server" AutoPostBack="True">
</asp:DropDownList></td>
<td style="width: 7px">
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td style="width: 7px">
</td>
</tr>
<tr>
<td style="height: 21px">
</td>
<td style="height: 21px; text-align: center">
<asp:ListBox ID="LB_Territorio" runat="server"></asp:ListBox></td>
<td style="width: 7px; height: 21px">
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
codigo vb
Imports System.Data
Imports System.Data.SqlClient
Partial Class frmControlAnidados
Inherits System.Web.UI.Page
Public cnx As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\SQL Server 2000 Sample Databases\NORTHWND.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not Page.IsPostBack) Then
Call CargaRegion()
Call CargarTerritorio(DD_Region.SelectedItem.Value)
End If
End Sub
Sub CargaRegion()
Dim strSQL As String = "Select * From Region "
Dim cnn As New SqlConnection(cnx)
Dim DS_Region As New DataSet
Try
cnn.Open()
Dim DA_Region As New SqlDataAdapter(strSQL, cnn)
DA_Region.Fill(DS_Region, "Region")
DS_Region.WriteXml("c:\region.xml")
DD_Region.DataTextField = "RegionDescription"
DD_Region.DataValueField = "RegionID"
DD_Region.DataSource = DS_Region.Tables("Region").DefaultView
DD_Region.DataBind()
Catch ex As Exception
Finally
cnn.Close()
End Try
End Sub
Sub CargarTerritorio(ByVal str_Id As String)
Dim strSQL As String = "Select TerritoryID, TerritoryDescription From Territories " & _
" Where RegionID ='" + str_Id + "' Order by TerritoryDescription "
Response.Write("SQL : " + strSQL)
Dim cnn As New SqlConnection(cnx)
Dim DS_Territorio As New DataSet
Try
cnn.Open()
Dim DA_Territorio As New SqlDataAdapter(strSQL, cnn)
DA_Territorio.Fill(DS_Territorio, "Territorio")
DS_Territorio.WriteXml("c:\territorio.xml")
LB_Territorio.DataTextField = "TerritoryDescription"
LB_Territorio.DataValueField = "TerritoryID"
LB_Territorio.DataSource = DS_Territorio.Tables("Territorio").DefaultView
LB_Territorio.DataBind()
Catch ex As Exception
Finally
cnn.Close()
End Try
End Sub
Protected Sub DD_Region_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DD_Region.SelectedIndexChanged
' Call CargarTerritorio(DD_Region.SelectedItem.Value)
End Sub
End Class |