Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/03/2013, 03:49
maialenlopez
 
Fecha de Ingreso: abril-2012
Mensajes: 449
Antigüedad: 12 años, 1 mes
Puntos: 7
obtener valor de dropdownlist dinamico

Hola; tengo una pagina aspx en la que genero controles dinámicos y los creo así:
Código aspx:
Ver original
  1. <asp:Button ID="Button1" runat="server" Text="Añadir Concepto" />
  2.     <br />
  3.     <asp:PlaceHolder ID="phDinamicControls" runat="server">
  4.     </asp:PlaceHolder>
Código asp.net:
Ver original
  1. Private Property QuantityDinamicControls() As Integer
  2.         Get
  3.             If ViewState("Quantity") = Nothing Then
  4.                 ViewState("Quantity") = 0
  5.             End If
  6.             Return DirectCast(ViewState("Quantity"), Integer)
  7.         End Get
  8.         Set(ByVal value As Integer)
  9.             ViewState("Quantity") = value
  10.         End Set
  11.     End Property
  12.  
  13.     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
  14.         Me.QuantityDinamicControls += 1
  15.         Me.validacionHojaVisas.Text = ViewState("Quantity")
  16.     End Sub
  17.  
  18.     Protected Overloads Overrides Sub CreateChildControls()
  19.         If Page.IsPostBack Then GenerateControls()
  20.     End Sub
  21.  
  22.     Private Sub GenerateControls()
  23.         Dim Quantity As Integer = 0
  24.         While Quantity <= Me.QuantityDinamicControls
  25.             Dim concepto As New DropDownList()
  26.             Dim facturableList As New RadioButtonList()
  27.             Dim txt1, txt2, txt3, txt4 As New TextBox()
  28.             Dim descripcion, facturable, orden, proyecto, importe, validacionFacturable, validacionOrden, validacionProyecto, validacionImporte As New Label()
  29.             concepto.Attributes.Add("style", "margin-bottom: 10px")
  30.             concepto.ID = "concepto" + (Quantity + 1).ToString()
  31.             concepto.SelectedIndex = ViewState("concepto_index")
  32.             'AddHandler concepto.SelectedIndexChanged, AddressOf concepto_SelectedIndexChanged
  33.             'concepto.AutoPostBack = True
  34.             descripcion.Attributes.Add("style", "margin-bottom: 10px")
  35.             descripcion.ID = "descricion" + (Quantity + 1).ToString()
  36.             descripcion.Text = "Descripción:"
  37.             txt1.Attributes.Add("style", "margin-bottom: 10px")
  38.             txt1.ID = "txt1" + (Quantity + 1).ToString()
  39.             txt1.Text = "Descripción..."
  40.             txt1.BackColor = Drawing.Color.Silver
  41.             txt1.Width = 250
  42.             facturable.Attributes.Add("style", "margin-bottom: 10px")
  43.             facturable.ID = "facturable" + (Quantity + 1).ToString()
  44.             facturable.Text = "Facturable:"
  45.             facturableList.Attributes.Add("style", "margin-bottom: 10px")
  46.             facturableList.ID = "facturableList" + (Quantity + 1).ToString()
  47.             facturableList.Items.Add("SI")
  48.             facturableList.Items.Add("NO")
  49.             facturableList.Enabled = False
  50.             facturableList.RepeatDirection = RepeatDirection.Horizontal
  51.             facturableList.RepeatLayout = RepeatLayout.Flow
  52.             validacionFacturable.Attributes.Add("style", "margin-bottom: 10px")
  53.             validacionFacturable.ID = "validacionFacturable" + (Quantity + 1).ToString()
  54.             validacionFacturable.Text = ""
  55.             validacionFacturable.ForeColor = Drawing.Color.Red
  56.             orden.Attributes.Add("style", "margin-bottom: 10px")
  57.             orden.ID = "orden" + (Quantity + 1).ToString()
  58.             orden.Text = "Orden:"
  59.             txt2.Attributes.Add("style", "margin-bottom: 10px")
  60.             txt2.ID = "txt2" + (Quantity + 1).ToString()
  61.             txt2.Text = "Orden..."
  62.             txt2.BackColor = Drawing.Color.Silver
  63.             txt2.Width = 90
  64.             importe.Attributes.Add("style", "margin-bottom: 10px")
  65.             importe.ID = "importe" + (Quantity + 1).ToString()
  66.             importe.Text = "Importe:"
  67.             txt4.Attributes.Add("style", "margin-bottom: 5px")
  68.             txt4.ID = "txt4" + (Quantity + 1).ToString()
  69.             txt4.Text = "Importe..."
  70.             'txt4.AutoPostBack = True
  71.             txt4.BackColor = Drawing.Color.Silver
  72.             txt4.Width = 50
  73.             AddHandler txt4.TextChanged, AddressOf Me.txt4_TextChanged
  74.             validacionImporte.Attributes.Add("style", "margin-bottom: 10px")
  75.             validacionImporte.ID = "validacionImporte" + (Quantity + 1).ToString()
  76.             validacionImporte.Text = ""
  77.             validacionImporte.ForeColor = Drawing.Color.Red
  78.  
  79.             phDinamicControls.Controls.Add(concepto)
  80.             phDinamicControls.Controls.Add(New LiteralControl("&nbsp;"))
  81.             cargarComboBoxConceptos(concepto)
  82.             phDinamicControls.Controls.Add(New LiteralControl("&nbsp;"))
  83.             phDinamicControls.Controls.Add(descripcion)
  84.             phDinamicControls.Controls.Add(New LiteralControl("&nbsp;"))
  85.             phDinamicControls.Controls.Add(txt1)
  86.             phDinamicControls.Controls.Add(New LiteralControl("&nbsp;"))
  87.             phDinamicControls.Controls.Add(facturable)
  88.             phDinamicControls.Controls.Add(New LiteralControl("&nbsp;"))
  89.             phDinamicControls.Controls.Add(facturableList)
  90.             phDinamicControls.Controls.Add(validacionFacturable)
  91.             phDinamicControls.Controls.Add(New LiteralControl("&nbsp;"))
  92.             phDinamicControls.Controls.Add(importe)
  93.             phDinamicControls.Controls.Add(New LiteralControl("&nbsp;"))
  94.             phDinamicControls.Controls.Add(txt4)
  95.             phDinamicControls.Controls.Add(validacionImporte)
  96.             phDinamicControls.Controls.Add(New LiteralControl("<br/>"))
  97.             phDinamicControls.Controls.Add(New LiteralControl("<br/>"))
  98.             Quantity += 1
  99.         End While
  100.     End Sub
  101.  
  102.     Private Function GetTxtControls() As String
  103.         Dim sb As New StringBuilder
  104.         Dim i As Integer = 0
  105.  
  106.         While i <= Me.QuantityDinamicControls
  107.             Dim concepto As String = "concepto" + (i + 1).ToString()
  108.             Dim validacionFacturable As String = "validacionFacturable" + (i + 1).ToString()
  109.             Dim validacionImporte As String = "validacionImporte" + (i + 1).ToString()
  110.             Dim facturableList As String = "facturableList" + (i + 1).ToString()
  111.             Dim descripcion As String = "descripcion" + (i + 1).ToString()
  112.             Dim facturable As String = "facturable" + (i + 1).ToString()
  113.             Dim importe As String = "importe" + (i + 1).ToString()
  114.             Dim txt1 As String = "txt1" + (i + 1).ToString()
  115.             Dim txt4 As String = "txt4" + (i + 1).ToString()
  116.  
  117.             Dim facturableListControl As RadioButtonList = TryCast(phDinamicControls.FindControl(facturableList), RadioButtonList)
  118.             Dim conceptoControl As DropDownList = TryCast(phDinamicControls.FindControl(concepto), DropDownList)
  119.             Dim validacionFacturableControl As Label = TryCast(phDinamicControls.FindControl(validacionFacturable), Label)
  120.             Dim validacionImporteControl As Label = TryCast(phDinamicControls.FindControl(validacionImporte), Label)
  121.             Dim descripcionControl As Label = TryCast(phDinamicControls.FindControl(descripcion), Label)
  122.             Dim facturableControl As Label = TryCast(phDinamicControls.FindControl(facturable), Label)
  123.             Dim importeControl As Label = TryCast(phDinamicControls.FindControl(importe), Label)
  124.             Dim txtControl1 As TextBox = TryCast(phDinamicControls.FindControl(txt1), TextBox)
  125.             Dim txtControl2 As TextBox = TryCast(phDinamicControls.FindControl(txt2), TextBox)
  126.             Dim txtControl3 As TextBox = TryCast(phDinamicControls.FindControl(txt3), TextBox)
  127.             Dim txtControl4 As TextBox = TryCast(phDinamicControls.FindControl(txt4), TextBox)
  128.  
  129.             sb.Append(validacionFacturableControl.Text & "<br />")
  130.             sb.Append(validacionImporteControl.Text & "<br />")
  131.             sb.Append(facturableListControl.Text & "<br />")
  132.             sb.Append(conceptoControl.Text & "<br />")
  133.             sb.Append(descripcionControl.Text & "<br />")
  134.             sb.Append(facturableControl.Text & "<br />")
  135.             sb.Append(ordenControl.Text & "<br />")
  136.             sb.Append(proyectoControl.Text & "<br />")
  137.             sb.Append(importeControl.Text & "<br />")
  138.             sb.Append(txtControl1.Text & "<br />")
  139.             sb.Append(txtControl2.Text & "<br />")
  140.             sb.Append(txtControl3.Text & "<br />")
  141.             sb.Append(txtControl4.Text & "<br />")
  142.  
  143.             i += 1
  144.         End While
  145.         Return sb.ToString
  146.  
  147.     End Function

Necesito que cuando txt4_textChanged me coja el valor que tiene el DropdownList.

Código vb.net:
Ver original
  1. Private Sub txt4_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  2.         Dim importeSelect As String
  3.         Dim tb As TextBox = DirectCast(sender, TextBox)
  4.  
  5.         importeSelect = tb.Text
  6.  
  7.         [B]COGER EL VALOR DEL DROPDOWNLIST[/B]
  8.  
  9. End Sub

Como puedo hacerlo?
__________________
Gracias por todo;

Un saludo