두 개의 선택 항목이있는 콤보 상자가 있습니다. 드롭 다운에서 옵션을 선택할 때 레이블의 텍스트가 그에 따라 바뀌길 원합니다. 어쩌면이 일을 할 수있는 쉬운 방법이 있을까요?콤보 상자에서 텍스트를 선택할 때 레이블 변경 VB.Net
답장을 보내 주시면 감사하겠습니다. 당신의 컨트롤에 따라
두 개의 선택 항목이있는 콤보 상자가 있습니다. 드롭 다운에서 옵션을 선택할 때 레이블의 텍스트가 그에 따라 바뀌길 원합니다. 어쩌면이 일을 할 수있는 쉬운 방법이 있을까요?콤보 상자에서 텍스트를 선택할 때 레이블 변경 VB.Net
답장을 보내 주시면 감사하겠습니다. 당신의 컨트롤에 따라
이
당신은
예를 들어, 콤보 상자의 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
을 설정해야합니다.
변화 ..
Private Sub YourComboBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YourComboBox.Click
UrLabel.Text = YourComboBox.SelectedValue
End Sub
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 파일을 설정해야
combobox.SelectedItem.Text에서 오류가 발생했지만 combobox.SelectedItem에서 오류가 발생했습니다. 아직도 도와 주니 감사합니다. – user3105998
해결책을 업데이트했습니다. 이것을 확인하십시오. –
If 문을 위해이 문단을 사용하고 있으며, 이것이 저에게 잘 돌아가고 있다는 것을 알아 냈습니다 : combobox.SelectedItem = "Text" – user3105998