2013-12-21 4 views

답변

2

당신은

예를 들어, 콤보 상자의 selectedIndex의 변경 이벤트에서이 코드를 작성할 필요가보십시오 :

Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList1.SelectedIndexChanged 
     Label1.Text= DropDownList1.SelectedItem.Text.ToString() 
End Sub 

을하고 PageLoad 이벤트에서 DropDownList.AutoPostBack=true을 설정해야합니다.

,
+0

combobox.SelectedItem.Text에서 오류가 발생했지만 combobox.SelectedItem에서 오류가 발생했습니다. 아직도 도와 주니 감사합니다. – user3105998

+0

해결책을 업데이트했습니다. 이것을 확인하십시오. –

+0

If 문을 위해이 문단을 사용하고 있으며, 이것이 저에게 잘 돌아가고 있다는 것을 알아 냈습니다 : combobox.SelectedItem = "Text" – user3105998

1

변화 ..

Private Sub YourComboBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YourComboBox.Click 

    UrLabel.Text = YourComboBox.SelectedValue 

End Sub 
0

Asp.net

콤보

당신은

Protected Sub cmb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmb.SelectedIndexChanged 
     lbl.Text = cmb.SelectedValue 
    End Sub 
(뒤에 코드) 의 AutoPostBack = "true"를

<table> 
      <tr> 
       <td><asp:ComboBox ID="cmb" runat="server" AutoPostBack="True"> 
      <asp:ListItem>1</asp:ListItem> 
      <asp:ListItem>2</asp:ListItem> 
      </asp:ComboBox></td> 

     <td> 
      <asp:Label ID="lbl" runat="server"></asp:Label> 
     </td> 
      </tr> 
     </table> 

에서 .aspx 파일을 설정해야

Asp.net

DropDownList로

당신은

Protected Sub ddl_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddl.SelectedIndexChanged 
     lbl.Text = ddl.SelectedValue 
    End Sub 
(뒤에 코드) 의 AutoPostBack = "true"를

<table> 
      <tr> 
       <td><asp:DropDownList ID="ddl" runat="server" AutoPostBack="True"> 
      <asp:ListItem>1</asp:ListItem> 
      <asp:ListItem>2</asp:ListItem> 
      </asp:DropDownList></td> 

     <td> 
      <asp:Label ID="lbl" runat="server"></asp:Label> 
     </td> 
      </tr> 
     </table> 

에서 .aspx 파일을 설정해야

관련 문제