Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.73/5 (4 votes)
See more:
I am very new to ASP.Net. And I am creation a simple web page that contains 3 fields.

1. Email (dropdownlist/combobox)
2. File upload button
3. Remarks -Normal textbox

Currently I have 4 emails in that dropdown list, how can I add one or more emails in future dynamically in the drop downlist...?

Note : The emails can add only the people who are all already mentioned in the dropdown list before.

Please suggest me...to proceed further..
Posted
Comments
Sinisa Hajnal 10-Oct-14 9:11am    
Where do you get the emails from? If you hard-coded them as part of your HTML there is nothing you can do. If they are in the database, then you don't have to do anything, you add to database and they are included in your dropdown box. Please clarify the question, provide some code / html and what exactly do you need.

Thank you
Member 9885328 10-Oct-14 9:24am    
I have provide rights to add an email to four people (A,B,C,D)

Then i shall provide the user name and password for all four people, so that when someone going to add an email in dropdown list i can check with uname and pwd then i can provide the permission to add an email in dropdownlist.

Note: Now i have an another question, if someone added the email successfully then close the site/browser and once again when they open the site, is there an added item will availbale in dropdownlist...? Please help to my question..
Thanks7872 10-Oct-14 9:40am    
http://stackoverflow.com/questions/17468956/how-to-add-an-item-to-a-drop-down-list-in-asp-net

1 solution

Sir please Follow Bind dropdown list[^] link and refer that link. Store that new emailid in database and after storing that email rebind that data in dropdown list or you can write Response.redirect(yourpage name). that will re open your site/page and rebind data..

Write dropdown binding code in page load.

XML
protected void Page_Load(object sender, EventArgs e)
{
  bindtoddl();
}

private void bindtoddl()
    {
         SqlConnection con = new SqlConnection(s);
        SqlCommand cmd = new SqlCommand("select FieldName from TableName", con);
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        sda.Fill(ds);
        DropDownList1.DataSource = ds;
        DropDownList1.DataTextField = "Email";
        DropDownList1.DataValueField = "ID";
        DropDownList1.DataBind();

      }                            
 
Share this answer
 
Comments
[no name] 10-Oct-14 9:53am    
Exactly how many times do you need to answer the same question?
Member 9885328 10-Oct-14 9:54am    
Only one time
[no name] 10-Oct-14 10:03am    
Why are you answering for jems_fams? Are you asking and answering your own questions?
[no name] 10-Oct-14 10:19am    
Sir please read it twice.
And for your kind information what you are looking for or can't solved. I have done more complex task than your question at my training period in collage.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900