Hi everyone
Can someone please give me an example on how to code a drop down list using the source code in c#.
Thanks!
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Julius Mnisi5 reputationPosted Mar 6, 2014, 10:55 PM EST
Lets say you want to use Laptops as your items this is an example of how you can code
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddllaps" runat="server">
<asp:ListItem>select a laptopasp:ListItem>
<asp:ListItem>Samsungasp:ListItem>
<asp:ListItem>Acerasp:ListItem>
<asp:ListItem>Lenovoasp:ListItem>
<asp:ListItem>Appleasp:ListItem>
<asp:ListItem>LGasp:ListItem>
<asp:ListItem>asp:ListItem>
asp:DropDownList>
KalaiRank #8,005 · 230 reputationPosted Mar 6, 2014, 11:03 PM EST
ddl.Items.Add(new ListItem("--Select--", "0"));
ddl.Items.Add(new ListItem("India", "In"));
ddl.Items.Add(new ListItem("Europe", "Eu"));
ddl.Items.Add(new ListItem("Iran", "Ir"));
ddl.Items.Add(new ListItem("Afghanistan", "Af"));
ddl.SelectedValue = "Ir";