displaying drop down list data into labels

Posted by Dina Shahin under ASP.NET on 10/24/2012 | Points: 10 | Views : 5962 | Status : [Member] | Replies : 4
Hello am developing an application with Asp using vb and i need to make a quick query throw a drop down list so how to get data into labels by selecting item in drop down list?




Responses

Posted by: Gow.Net on: 10/24/2012 [Member] Starter | Points: 25

Up
0
Down
try this
<asp:DropDownList ID="DropDownList2" runat="server"  AutoPostBack="true"

onselectedindexchanged="DropDownList2_SelectedIndexChanged">
<asp:ListItem>hai</asp:ListItem>
<asp:ListItem>hello</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

 protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)

{
Label8.Text = DropDownList2.SelectedItem.Text;
}


gowthaman8870226416

Dina Shahin, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dina Shahin on: 10/24/2012 [Member] Starter | Points: 25

Up
0
Down
can you pleas convert it to VB
I've tried this one and it's not working :
Rs.Open("select * from emp_data where emp ='" + emp.Text + "'", Cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

room_no.Text = Rs("room_no").Value
Rs.Close()


Dina Shahin, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seng2hs on: 10/25/2012 [Member] Starter | Points: 25

Up
0
Down
<form method="get" action="simpleform.asp">
<select name="itemid" id="itemid">
<option value="1">Choose1</option>
<option value="2">Choose2</option>
<select>
<input type="submit" name="btn" value="submit">
</form>


ASP:

'to get value from dropdown(user form method 'post')
empname=request.form("itemid")

Rs.Open("select * from emp_data where emp ='" + empname + "'", Cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

room_no.Text = Rs("room_no").Value
Rs.Close()

Dina Shahin, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sourabh07 on: 10/25/2012 [Member] Starter | Points: 25

Up
0
Down
hi..

you can perform your operation.....while working on the SelectedIndexChanged event of the DropDownList control......

After selecting the particular item of the dropdownlist then it will postback and enters into the code file....and perform your functionality accordingly.

Sourabh07

Dina Shahin, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response