Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/04/2003, 10:25
Avatar de vamp_02
vamp_02
 
Fecha de Ingreso: febrero-2002
Ubicación: Santiago de Chile
Mensajes: 367
Antigüedad: 23 años, 1 mes
Puntos: 0
Hola ahora me toco a mi.....

estuve investigando y mira lo que encontre....


<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<SCRIPT LANGUAGE="vb" RUNAT="server">
'// open the countries listbox in codebehind when page load
Private Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
'// keep the connectionstring in web.config
Dim myconn As New SqlConnection(ConfigurationSettings.appSettings("C onnectionString"))
'// read in the sqlcommand
Dim myCmd As SqlCommand = New SqlCommand("SELECT country FROM canmexusa1", myConn)
'// open connection
myConn.Open()
'// read and execute
Dim myReader As SqlDataReader = myCmd.ExecuteReader()
'// read in and binddata
country.DataSource = myReader
country.DataTextField = "country"
country.DataValueField = "country"
country.DataBind()

' // close conn and the datareader
myConn.Close()
myReader.Close()


'// insert some text to display
country.Items.Insert(0, "<- Select country ->")

End If
End Sub

'// now we do much the same for regions listbox and to open it with a
''// ONSELECTEDINDEXCHANGED="Click_onchange" in country lsitbox
Private Sub Click_onchange(sender As Object, e As EventArgs)
Dim itemValue As String = country.SelectedItem.Value
Dim myconn As New SqlConnection(ConfigurationSettings.appSettings("C onnectionString"))
Dim myCmd As SqlCommand = New SqlCommand("SELECT ID, region FROM canmexusa where country='" & country.SelectedItem.Value & "'", myConn)
myConn.Open()
Dim myReader As SqlDataReader = myCmd.ExecuteReader()

region.DataSource = myReader
region.DataTextField = "region"
region.DataValueField = "region"
region.DataBind()

myConn.Close()
myReader.Close()

region.Items.Insert(0, "<- Select province/state ->")
region.Visible = True
findcountry_region.Visible = True
End Sub


'// this last is just to show you what you did when clicking on the form
Private Sub findcountry_region_Click(sender As Object, e As EventArgs)
dim findcountry_region_Click as string
Dim itemValue As String = region.SelectedItem.Value
Label1.Text = "Your choice: " & region.SelectedItem.Value & " in " & country.SelectedItem.Value & "."
Country.Visible = False
region.Visible = False
findcountry_region.Visible = False
End Sub
</SCRIPT>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>double-combo-asp.net, sagas.net</title>
</head>
<body bgcolor="#FFFFFF">

<form runat="Server">

<asp:listbox id="country" runat="server" ROWS="1" DATAVALUEFIELD="country" DATATEXTFIELD="country" ONSELECTEDINDEXCHANGED="Click_onchange" autopostback="true" ></ASP:LISTBOX>
<br>

<asp:listbox id="region" runat="server" ROWS="1" DATAVALUEFIELD="region" DATATEXTFIELD="region"VISIBLE="False"></ASP:LISTBOX>
<br>
<asp:button id="findcountry_region" text="Write Combination" OnClick="findcountry_region_Click" VISIBLE="False" runat="server"/><br>

<asp:Label id="Label1" Font-Name="Verdana" Font-Size="10pt" runat="server" />

</form>

</body>
</html>



te servira.....yo creo que si.......asi que aca estamos.....

__________________
yerba mala nunca....te la fumes...