Click here to Skip to main content
12,072,067 members (58,270 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET DropDownList

I have a web Form with one DropDownList which read it's data from a table.
and I have a button next to the DropDownList which run's an insert query to add a new item to the table.
Until now every thing is fine, but what I need now is to refresh the DropDownList and automatically select the new inserted item.

Hope to solve this problem
Thank you
Posted 20-Jan-13 0:31am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Before insert the data to the database table, store the value in some variable

for ex.
Dim strNewValue$="New Data"

InsertDatabase("New Data") 'Ur functionality to insert in database

Dim dt as datatable = drpYourdropdown.datasource
Dim dr as datarow

Try the above code...
Nasser Abu Farah 20-Jan-13 6:03am
Thank you for your response
But can you explain using C# because I am not familiar with VB coding.
Than you
Sandeep Mewara 20-Jan-13 7:24am
Not exact but something like:
dynamic strNewValue = "New Data";

InsertDatabase("New Data");
//Ur functionality to insert in database

DataTable dt = drpYourdropdown.datasource;
DataRow dr = null;
dr = dt.NewRow();
dr[0] = strNewValue;
drpYourDropdown.datasource = dt;

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160208.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100