| | |
Master/Detail DropDownList and DataGrid
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
•
•
Join Date: Dec 2008
Posts: 21
Reputation:
Solved Threads: 0
hi myrequirement is i have two dropdownlist one is country n other is statename.....wen i selelc india corresponding states shls come...but i see my selected index function is different from urs...pls explain tat...n is my code right..iam not getting the output....
one more thing how did u create the table for tat category..like i inserted 79 countries.....with id...now in state table i need to insert 28 states for india..
stateid statename countryid.....or i need to have stateid statename1........statename28 countryid
one more thing how did u create the table for tat category..like i inserted 79 countries.....with id...now in state table i need to insert 28 states for india..
stateid statename countryid.....or i need to have stateid statename1........statename28 countryid
I had the same problem my DDL doesnt talk to me back if I just select and do nothing, I couldnt figure out what was the problem because I had selectedChanged event but then until I had a button which I named to go and I didnt code anything on the button I just drag and dropped it so I select something from the DDL and click in the button and it worked just try that to see if its working then u will fix that problem later
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
U jst need to make sure that the countryID on the state table is corresponding to the one on the country name, then you can have a select stateme like this on ur dataadpater
Im sory I cant read your code can u edit it and make it C# instead of just text, its killing me
[ Code=C# ]
Paste code here dont leave
[ /Code ]
there souldnt be any space in between ur square brackets
SQL Syntax (Toggle Plain Text)
SELECT * FROM State WHERE CountryID = ddlCountries.selectedValue;
Im sory I cant read your code can u edit it and make it C# instead of just text, its killing me
[ Code=C# ]
Paste code here dont leave
[ /Code ]
there souldnt be any space in between ur square brackets
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
•
•
Join Date: Dec 2008
Posts: 21
Reputation:
Solved Threads: 0
C# Syntax (Toggle Plain Text)
protected void Page_Load(object sender, EventArgs e) { Response.Write("sql is connected"); SqlDataAdapter da = new SqlDataAdapter("select countryid,countryname from countryname", cn); DataSet ds = new DataSet(); da.Fill(ds,"countryname"); ddlcountryname.DataSource = ds.Tables["countryname"]; ddlcountryname.DataTextField = "countryname"; ddlcountryname.DataValueField = "countryid"; ddlcountryname.DataBind(); } protected void ddlcountryname_SelectedIndexChanged(object sender, EventArgs e) { string country_id; country_id = ddlcountryname.SelectedValue.ToString(); SqlDataAdapter da1=new SqlDataAdapter("select stateid,statename from statename where countryid=' country_id'",cn); DataSet ds1 = new DataSet(); da1.Fill(ds1, "statename"); ddlstatename.DataSource = ds1.Tables["statename"]; ddlstatename.DataTextField = "statename"; ddlstatename.DataValueField = "stateid"; ddlstatename.DataBind(); }
Last edited by peter_budo; Dec 10th, 2008 at 6:50 am. Reason: Correcting closing tag from [\code] to [/code]
SqlDataAdapter da1=new SqlDataAdapter("select stateid,statename from statename where countryid=' country_id'",cn); Why your country_ID which you declared as a string is within single and double qoutation marks
Try this and see if it helps
SqlDataAdapter da1=new SqlDataAdapter("select stateid,statename from statename where countryid = " + country_id ,cn); Last edited by Traicey; Dec 10th, 2008 at 5:57 am.
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: How to Send email using asp.net with C#
- Next Thread: how to print the contents of text box
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class commonfunctions compatible confirmationcodegeneration content contenttype countryselector courier dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formatdecimal forms formview gridview gudi homeedition iis javascript jquery listbox menu microsoft mouse mssql nameisnotdeclared news opera panelmasterpagebuttoncontrols problem redirect registration relationaldatabases reportemail schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming webservice youareanotmemberofthedebuggerusers





