.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

populate combo

Posted By:      Posted Date: August 26, 2010    Points: 0   Category :ASP.Net

i have two combo cboCountry and cboCity

i want to change cboCity with new value.

protected void cboCountry_TextChanged(object sender, EventArgs e)
            SqlCommand cmd = new SqlCommand("SELECT * FROM [Country] where country='" + cboCountry.SelectedItem + "'", new SqlConnection(ConfigurationManager.AppSettings["ConString"]));

            SqlDataReader ddlValues;
            ddlValues = cmd.ExecuteReader();

            cboCity.DataSource = ddlValues;
            cboCity.DataValueField = "City";
            cboCity.DataTextField = "City";


View Complete Post

More Related Resource Links

how to populate a dropdown box based on selectedvalue in another dropdown/combo box



I am new to MVC.  Can anyone show me how to populate a dropdown list box based on selected value in another

dropdown list box?  Say, for example, the first dropdown is a list of car manufactures.  When a user selected a manufacture from that dropdown list, the second dropdown would list would automatically gets populated with all the car models for that manufacture. 

Any help is greatly appreciated.



Gmail style multiple Sign-in type combo...is it possible in asp.net?


I am developing a multi-company application and want my users to give the functionality like the following to switch companies.


Is this possible? then how?

Please help


Using a trigger or anything else to populate two tables


Hi! I'm creating an application that's supposed to first add a record to table1, and then get the ID from that record to use when adding a record to table2, to be able to associate these two records with eachother.

The user gets to type in some values that goes to table1, and some values that goes to table2, but before the insert statement for table2 is executed i need the ID from the recently added record in table1. Some dude told me to use a trigger for the autopopulate purpose, but does that really work when i also need to save some values that's user input, and when those values doesn't get saved in table1?

Are there any other way to do this or can i send values to a trigger? I'm new to triggers and stored procedures, i don't have any particular knowledge of this, any help is appreciated!


Regards, Monsterbadboll

Is it possible to populate property choices from a database?


I'm creating my first server control, and have it working where I can set up an enum and the user can set a property's choices,  based off of that enum.  But I'd like it to pull records from a database and populate the list of choices for the property from a database.  This would allow me to add a new "Host System" to the database, and the other designers wouldn't have to get a new copy of the dll.



populate report viewer by code


Hi all

I have a button "Show Report" to show some data from table

what I should write under this button to populate the reports ?

problem...i want a list item to populate all data in gridview!!!


i have a dropdownbox and a gridview

what I want is to have a list item which populates all data in a gridview.

I have tried using list item selected value=0 but to no avail.

what is the easiest way to achieve this?

search multiple words into textbox and populate all records in gridview related those keywords


I have a textbox and a gridview which is bound to a table

what I want to achieve is a solution where lets say there are two records - e.g. "1. Book and 2. Red", i want a user to type in those words and the gridview shows the results as followed;

1. Book

2. Red

I have set up the sql data source and everything and my like operator is this...

LIKE '%' + @record + '%'

how can I solve this problem?

Trying to get Roles to populate a checkboxlist based on tutorial and having issues.


I have been using the following tutorial and had to convert the code to C# for my project, now i cant get the code to work, im getting red line under the word "in" in the UpdateRolesFromList,
i tried to add a datasource on page load for the checkboxlist like so RoleList.DataSource = PopulateRoleList(User.Identity.Name.ToString());

and gives me error saying cannot implictly convert type 'void' to 'object'


What am i missing, that when i load the page or even do a search it never displays the checkbox list as it shows in the tutorial?

        protected void Page_Load(object sender, EventArgs e)

        public void PopulateRoleList(string userName)
            string[] roleNames = null;
            string roleName = null;
            roleNames = Roles.GetAllRoles();
            foreach (string roleName_loopVariable in roleNames)
                roleName = r

Dynamically Populate a DVWP depending on selected item



I am wanting to create a dashboard page with several data view web parts which dynamically populate depending on what item is selected in a separate web part (drop down form or just a list of links).  Can someone please point me to a tutorial or documentation on how to pass data between web parts or to a DVWP?  I have searched for a few hours and not been able to find anything useful.



How to pre-populate field values of ListB from ListA


I want to know if there is an easy way to the pre-populate field values to ListB from ListA. 

In ListA I have ColumnA, ColumnB and ColumnC.  In ListB, I have Column1, Column2 and Column3.

When I add a new item in ListB, Column1 is a lookup field tied to ColumnA.  So, if I select a value from the lookup list, I want it to automatically populate ColumnB value to Column2 and ColumnC value to Column3.  Can this be done without programming?

Populate Treeview upon entered criteria and page action without complete page posting on client side


1. I have a treeview on left side in a panel in my aspx page and I have a Text box and a Search button on the right panel. On entering a search criteria and clicking the Search button, I want to get the data needed for the treeview (FYI - I have a webservice call for that) and then populate the treeview completely but keep it collapsed to the root node.

  Each time I enter the search criteria and click the Search button, I don't want to post the entire page (and also don't like the page flicker), how can I achieve this? I know that in order to avoid complete postback upon Search button click, I can do so by client callback and get the data needed for the treeview, but in this case, I have to build the treeview nodes as table - row/cells and handle all the events and handlers myself, which I want to avoid (also means that I won't be able to take advantage of the inherent expand and collapse capabilities of the Treeview). On the other hand, if I use the OnTreeNodePopulate event handling of the Treeview control, using the C# script code on the aspx markup, it doesn't recognize the entered criteria in the Text box. So either way,

Adjacent combo boxes take space according to their data on google chrome

I have a page where I want to keep several combo boxes adjacent to each other. I have put them in divs that are floated left.This works fine in IE, Firefox. But when I render the same page on Chrome I observe the uneven gap between combo boxes. Upon analysis I found out that each combo box is occupying space based on the data inside it.This happens because on Safari and Chrome, the option list control is placed differently as compared to that on IE and Firefox.Please see the following code from ComboBox.pre.js (in AjaxControlToolkit source/Server/) // force inline display on Safari by moving the list to the bottom of the form. if (Sys.Browser.agent === Sys.Browser.Safari || Sys.Browser.agent === Sys.Browser.WebKit) { this.get_element().removeChild(optionListControl); var parent = this.get_element().parentNode; while (typeof (parent) != typeof (document.forms[0])) { parent = parent.parentNode } var safariListContainer = document.createElement('div'); safariListContainer.className = this.get_element().className; safariListContainer.appendChild(optionListControl); parent.appendChild(safariListContainer); } This is how it looks:I have tried doing the following but none of them helped:Changed the RenderMode of combo box to 'block' fro

Populate combobox

i have 2 combo, cboCountry and cboCity in file default.aspx using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using System.Data.SqlClient; using System.Configuration;   protected void cboCountry_TextChanged(object sender, EventArgs e)         {             SqlCommand cmd = new SqlCommand("SELECT * FROM [Country] where country='" + cboCountry.SelectedValue + "'", new SqlConnection(ConfigurationManager.AppSettings["ConString"]));             cmd.Connection.Open();   <==== ERROR HERE             SqlDataReader ddlValues;             ddlValues = cmd.ExecuteReader();             cboCity.DataSource = ddlValues;             cboCity.DataValueField = "City";             cboCity.DataTextField = "City";             cboCity.DataBind(); &nb

EF4/Linq Eager Loading with Include fails to populate all results

Hi, I'm trying out EF4 as part of a .Net 4.0 WCF service. The aim of the service is to return document data as an array of entity objects to any of our ASP.Net apps. The apps are still in .Net 2.0. Due to the nature of the solution I've disabled LazyLoading at context level. I started with this:var revQuery = from revs in context.DocRevision                         where (revs.ID == myIDVar)                         select revs;  Everything works ok, I receive the correct number of populated objects. However when I add an Include into my query to allow us to pickup fields from a related table that has a defined navigation only the first record is returned fully populated to a calling application:var revQuery = from revs in context.DocRevision.Include("StaffNames")                         where (revs.ID == myIDVar)                         select revs;  The array is the correct size but all elements after the first are blank, default placeholders. Its like using the Include has reverted to LazyLoading and I can't seem to kick it into line. Anyone else had this problem?

WPF Databinding a combo box

I have looked at some of the other linked related articles but I still can't get it. Simply I have 2 related tables Orders and Customers when I am editing an order I want to display the Customer in a Combobox. Let's say I wish to change the customer using a cbo The Customer Combo box should be populated with all Customers from the customer table the currently selected customer should be the current customer in the Order Table  for the Order I am Viewing The display member should be the customers name the tables are related with a CustomerID field in each table The data is EDMX   I have done some work on databinding in WPF and I can get combo boxes populated with Data but it's just not quite there. I can't seem to get the selected cbo customer to update to the Orders  

populate dataset from XML obtained from URL

I'm building a website for a client who gets their news from an external source. Their news is in XML and is retrieved via a URL similar to this http://news.domainname.com/LatestNewsXML?custID=1234 I was hoping to grab this news and use it to populate a dataset, could anyone please provide a sample code of how I could do this?  I've developing in .Net 2.0 with C#. Many thanks.

populate specific data from table

I am trying to build an application.I have table in my database named tbl_customer.I am able to display all the customers information using MVC i.e Name,Designation, Address, PhoneNumber, Sex etc.Now I Want To Display Customer only Having Sex "Female" (Sort Out Data From tbl_customer)How I Can Do This???I Am New To Asp.net.. I Am Using VS 2010, SQL Server 2005Help In This Context, Appreciated In Advance..Regards
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend