473,387 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Asp .net : Populate items in dropdown list based on another drop down list

hi
i am developing website which is a online shoping
i want to populate two dropdownlist, in which the first dropdownlist should place the list of a paticular product and the next dropdownlist should populate with the models of corresponding product of first dropdownlist1 and the price should be placed on the textbox
please sought out my problem its urgent,my boss kept knife on my throat
thanku in advance
Nov 24 '07 #1
6 4810
Shashi Sadasivan
1,435 Expert 1GB
Hi peerraghu,
Welcome to TSDN.

When you select an item in the drop down list you can opt for an event handler to be triggered.
Use that to populate the other drop down list.

The evnt handler should be called something like Editvaluechanged. (sorry I have been working with Windows application for a bit too long, forgot the ASP .Net stuff)

Do give our regards to your boss :D
Nov 25 '07 #2
hi
i am developing website which is a online shoping
i want to populate two dropdownlist, in which the first dropdownlist should place the list of a paticular product and the next dropdownlist should populate with the models of corresponding product of first dropdownlist1 and the price should be placed on the textbox
please sought out my problem its urgent,my boss kept knife on my throat
thanku in advance
Hi Raghu,

you can write a query in the SelectedIndexChanged event of the first DropDownList to fill your Second dropdown. I guess this will work.
Nov 26 '07 #3
Hi Raghu,

you can write a query in the SelectedIndexChanged event of the first DropDownList to fill your Second dropdown. I guess this will work.

hi usha thanks for your reply but my problem is
if i select a country from dropdownlist1 then it should give all states of selected country in dropdownlist2 and its capital should be placed in the textboxt box..
but i am getting all list of states of all country,if v select one country..

please sought out my problem
thank you in advance
Nov 30 '07 #4
mzmishra
390 Expert 256MB
Hi Raghu,

I think you are following the steps said by Usha and Shashi.
The only reason I can see to your problem is your select query for the state is wrong.You have probably missed the where clause
Nov 30 '07 #5
Hi Raghu,

I think you are following the steps said by Usha and Shashi.
The only reason I can see to your problem is your select query for the state is wrong.You have probably missed the where clause
just explain in detail its urgent
Nov 30 '07 #6
Hi Raghu,

I think you are following the steps said by Usha and Shashi.
The only reason I can see to your problem is your select query for the state is wrong.You have probably missed the where clause

hi mishra
just look at my code where i did mistake

Expand|Select|Wrap|Line Numbers
  1.   protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (Page.IsPostBack == false)
  4.         {
  5.             SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data source=vubrain4");
  6.             SqlDataAdapter da = new SqlDataAdapter("select countyr_id,countryname from country_master", con);
  7.             DataSet ds1 = new DataSet();
  8.             da.Fill(ds1, "country_master");
  9.             dd1.DataSource = ds1.Tables["country_master"];
  10.             dd1.DataTextField = "countryname";
  11.             dd1.DataValueField = "countyr_id";
  12.             dd1.DataBind();
  13.         }
  14.      }
  15.  protected void dd1_SelectedIndexChanged(object sender, EventArgs e)
  16.     {
  17.         string countryid;
  18.         countryid = dd1.SelectedValue;
  19.         SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data source=vubrain4");
  20.         SqlDataAdapter da1 = new SqlDataAdapter("SELECT StateID,StateName FROM tblSate_Master S INNER JOIN tblStateCountryRelation SC ON S.StateID=SC.StateId WHERE CountryId='" & countryid & "'");
  21.         DataSet ds1 = new DataSet();
  22.         da1.Fill(ds1, "countrystate");
  23.         dd2.DataSource = ds1.Tables["countrystate"];
  24.         dd2.DataTextField = "statename";
  25.         dd2.DataValueField = "stateid";
  26.         dd2.DataBind();
  27.  
  28.  
  29.     }
it showing two error report

1.
The best overloaded method match for 'System.Data.SqlClient.SqlDataAdapter.SqlDataAdapt er

2. cannot convert from 'string' to 'System.Data.SqlClient.SqlCommand'

please sought out my mistake

thank you
Nov 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: kmnotes04 | last post by:
Is it possible to link one drop-down box to another? For example, if a name is chosen from a drop-down list, can another drop-down list then automatically display the person's office as a result of...
0
by: VB Programmer | last post by:
I have a user control that has a drop down list. Initially it has no items. The items are loaded into the drop down list in the Page_Load event of the user control. Basically if...
1
by: Glenn M | last post by:
whats the easiest way of removing all items ( regardless or their values) from an asp.net server side dropdown list? thanks glenn
2
by: jagdishl | last post by:
hi I have to populate the second drop down list based on the selection made in the previous drop down list.I have to chose between two values in the first dropdown list i.e city and county.This is...
1
by: bbdobuddy | last post by:
Hi, What event do I use when I want to capture the time when the user clicks an item in a list box or a drop down list. The Selected Index Changed event isn't working for me. What I am...
0
by: JamesW | last post by:
Hi. VS 2003 (VB.Net) I want to display data on a webForm based on what the user selects from a DropDownList. So, for example, if the user selects customer name from the DDL I want the...
0
by: JenniferG | last post by:
I've worked with ASP.NET but don't know much about ASP at all. I have the following code. I would like to get a person' birthday and phone number text box populated when the person's name is selected...
0
by: yosri2005 | last post by:
Hello, I'm sure many of you have seen the error message in the subject. I found quiet a few posts on the web regarding this issue, but the ones I saw mainly tackle this issue when you have a...
1
by: TechnoAtif | last post by:
HI.. I am looking for php code that will enable me to hide/show a text box based on the users previous drop down list response. If javascript comes into use for it, its a welcome solution (1)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.