In my web site I have a drop down list and repeatedly I assign different values to the same drop down list so that I can see number of drop down lists wiith different values.
The drop down lists can be edited. I need to get the new values of the drop down lists at Submit.
But I have no idea how I can get the values. Please someone help me.
manjayweer
Member
18 Points
15 Posts
Get edited values of the repeated drop down lists
May 17, 2012 09:30 AM|LINK
Hi,
In my web site I have a drop down list and repeatedly I assign different values to the same drop down list so that I can see number of drop down lists wiith different values.
The drop down lists can be edited. I need to get the new values of the drop down lists at Submit.
But I have no idea how I can get the values. Please someone help me.
Thank You.
AmalO.Abdull...
Contributor
3116 Points
764 Posts
Re: Get edited values of the repeated drop down lists
May 17, 2012 09:38 AM|LINK
Hi,
as i understand that you want to get all the values of your ddl in button click
okay try this , my code will store you ddl values in array of string
vb
Dim l() As String For i As Integer = 0 To drp.Items.Count - 1 l(i) = drp.Items(i).Value NextC#
string[] l = null; for (int i = 0; i <= drp.Items.Count - 1; i++) { l[i] = drp.Items(i).Value; }manjayweer
Member
18 Points
15 Posts
Re: Get edited values of the repeated drop down lists
May 18, 2012 03:09 AM|LINK
Hi,
Thank you very much for your help. But it doesn't work for me.
I want to get the selected values of the drop down lists not the values of the drop down list.
Please help me.
ramiramilu
All-Star
95503 Points
14106 Posts
Re: Get edited values of the repeated drop down lists
May 18, 2012 07:38 AM|LINK
use Dropdownlist.SelectedItem.Text or use Dropdownlist.SelectedItem.Value to get selected item from dropdownlist....
In case you want all dropdownlists selected items then you need to iterate Page.Control and find Dropdownlist's and then get those selectd items...
Thanks,
JumpStart
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: Get edited values of the repeated drop down lists
May 22, 2012 04:53 AM|LINK
If you want to get the selected value on submit,please read the sample:
<asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> </asp:DropDownList> <asp:Button ID="Button1" Text="Submit" OnClick="Button_Click" runat="server" /> <asp:Label ID="Label1" runat="server" />protected void Button_Click(object sender, EventArgs e) { Label1.Text = "You selected: " + DropDownList1.SelectedItem.Text + "."; Or Label1.Text = "You selected: " + DropDownList1.SelectedValue; }Feedback to us
Develop and promote your apps in Windows Store