31/07/2007, 06:20
|
| | Fecha de Ingreso: mayo-2007
Mensajes: 8
Antigüedad: 17 años, 7 meses Puntos: 0 | |
Re: Problemas con un DropDownList Creo que el problema no viene de ahi:
Os paso el codigo a ver que os parece:
Código:
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports System.Data
Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
TipoUsuarioddl.Items.Insert(0, New ListItem("-tipo usuario-", ""))
TipoUsuarioddl.Items.Insert(1, New ListItem("Escuela Idioma", ""))
TipoUsuarioddl.Items.Insert(2, New ListItem("Alojamiento", ""))
TipoUsuarioddl.Items.Insert(3, New ListItem("Demandante", ""))
TipoUsuarioddl.Items.Insert(4, New ListItem("Alumno", ""))
End If
End Sub
Public Sub TipoUsuarioddl_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TipoUsuarioddl.SelectedIndexChanged
Select Case TipoUsuarioddl.SelectedIndex
Case 0
Dim dt As DataTable = New DataTable()
dt.Columns.Add(New DataColumn("Text", GetType(String)))
dt.Columns.Add(New DataColumn("Value", GetType(String)))
dt.Rows.Add(CreateRow("-tipo-", "0", dt))
Tipoddl.DataSource = dt
Tipoddl.DataBind()
Tipoddl.Enabled = False
Case 1
Tipoddl.Enabled = True
Dim dt As DataTable = New DataTable()
dt.Columns.Add(New DataColumn("Text", GetType(String)))
dt.Columns.Add(New DataColumn("Value", GetType(String)))
dt.Rows.Add(CreateRow("-tipo-", "0", dt))
dt.Rows.Add(CreateRow("Universidad", "1", dt))
dt.Rows.Add(CreateRow("Academia", "2", dt))
Tipoddl.DataSource = dt
Tipoddl.DataBind()
Case 2
Tipoddl.Enabled = True
Dim dt As DataTable = New DataTable()
dt.Columns.Add(New DataColumn("Text", GetType(String)))
dt.Columns.Add(New DataColumn("Value", GetType(String)))
dt.Rows.Add(CreateRow("-tipo-", "0", dt))
dt.Rows.Add(CreateRow("Apartamentos / Piso compartido", "1", dt))
dt.Rows.Add(CreateRow("Residencias", "2", dt))
dt.Rows.Add(CreateRow("Familia", "3", dt))
dt.Rows.Add(CreateRow("Hotel", "4", dt))
Tipoddl.DataSource = dt
Tipoddl.DataBind()
Case 3
Dim dt As DataTable = New DataTable()
dt.Columns.Add(New DataColumn("Text", GetType(String)))
dt.Columns.Add(New DataColumn("Value", GetType(String)))
dt.Rows.Add(CreateRow("-tipo-", "0", dt))
Tipoddl.DataSource = dt
Tipoddl.DataBind()
Tipoddl.Enabled = False
Case 4
Dim dt As DataTable = New DataTable()
dt.Columns.Add(New DataColumn("Text", GetType(String)))
dt.Columns.Add(New DataColumn("Value", GetType(String)))
dt.Rows.Add(CreateRow("-tipo-", "0", dt))
Tipoddl.DataSource = dt
Tipoddl.DataBind()
Tipoddl.Enabled = False
End Select
End Sub
Function CreateRow(ByVal Text As String, ByVal Value As String, ByVal dt As DataTable) As DataRow
Dim dr As DataRow = dt.NewRow()
dr(0) = Text
dr(1) = Value
Return dr
End Function
End Class
Gracias |