Ver Mensaje Individual
  #7 (permalink)  
Antiguo 14/01/2004, 14:22
Avatar de vamp_02
vamp_02
 
Fecha de Ingreso: febrero-2002
Ubicación: Santiago de Chile
Mensajes: 367
Antigüedad: 22 años, 3 meses
Puntos: 0
bueno, lo primero...

En el Access:

Tabla 1:

provee:

idunico campo pk (autonumerico)
nombre texto....etc


tabla 2:

producto:

idunico viene de la tabla provee (numerico)
idproducto pk
nmbr_prod texto

ya....

Ahora

asp.net

Primero hay que cargar el drop al entrar a la pagina...en el page_load, cierto...

prueba este codigo...y me avisas:

<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data" %>
<%@ Page Language="vb" Debug="true"%>
<html>
<head>
<title>Seleccion</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script runat="server">
Sub Page_Load(obj as object, e as eventargs)
If NOT IsPostBack Then
Dim objConn As New OleDbConnection (ConfigurationSettings.appSettings("fact"))
Dim sSQL as string
sSQL = "select idunico,nombre from provee"
'response.Write(ssql)
Dim objCmd As New OleDbCommand (sSQL, objConn)
'// open connection
objConn.open
Dim Reader as OleDbDataReader
Reader=objCmd.ExecuteReader()
'// read in and binddata
provee.DataSource = Reader
provee.DataTextField = "nombre"
provee.DataValueField = "idunico"
provee.DataBind()
' // close conn and the datareader
objConn.Close()
Reader.Close()
'// insert some text to display
provee.Items.Insert(0, "<-provee->")
end if
end sub

Sub cambio(obj as object, e as eventargs)
If NOT IsPostBack Then
dim proveeid as integer
Dim objConn As New OleDbConnection (ConfigurationSettings.appSettings("fact"))
Dim sSQL as string
sSQL = "select idproducto,nmbr_prod from producto where idunico =" & proveeid &";"
'response.Write(ssql)
Dim objCmd As New OleDbCommand (sSQL, objConn)
'// open connection
objConn.open
Dim Reader as OleDbDataReader
Reader=objCmd.ExecuteReader()
'// read in and binddata
produ.DataSource = Reader
produ.DataTextField = "nmbr_prod"
produ.DataValueField = "idproducto"
produ.DataBind()
' // close conn and the datareader
objConn.Close()
Reader.Close()
'// insert some text to display
produ.Items.Insert(0, "<-producto->")
end if
end sub


</script>
</head>
<body>
Seleccione un proveedor:
<asp:DropDownList ID="provee" DataTextField="nombre" DataValueField="idunico" AutoPostBack="true" OnSelectedIndexChanged="cambio"></asp:DropDownList><br><br><br>
seleccione un Producto de este proveedor:
<asp:DropDownList ID="produ" DataTextField="nmbr_prod" DataValueField="idproducto"></asp:DropDownList>
</body>
</html>



<<<<---------------------------->>>>>>
un truco:

coloca esto en el web.config

<configuration>
<appSettings>
<add key="fact" value="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=[ruta de la bd completa] D:\facturas\facturas.mdb" />
</appSettings>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>




me cuentas

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

Última edición por vamp_02; 14/01/2004 a las 14:24