| | |
on selecting country from one dropdownlist ...states of selected country is not getti
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Dec 2008
Posts: 21
Reputation:
Solved Threads: 0
Re: on selecting country from one dropdownlist ...states of selected country is not getti
0
#11 Dec 10th, 2008
•
•
Join Date: Dec 2008
Posts: 2
Reputation:
Solved Threads: 0
Re: on selecting country from one dropdownlist ...states of selected country is not getti
0
#12 Dec 11th, 2008
•
•
•
•
pls give me the complete code for it ..i tryed but not getting the output..pls help..iam pasting the code here but no output
my database is something like this...i have two tables countryname(countryid identity(1,1),countryname) and statename(stateid identity(100,1),statename,countryid)asp.net Syntax (Toggle Plain Text)
SqlConnection cn = new SqlConnection(ConfigurationSettings.AppSettings["con"].ToString()); 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(); }
so i have inserted 78 countries in country table in tat 73rd is india...
n i have inserted states of india in statename table(28)..how to get india's states wen india in selected
I did a similar one But now sure whether this helps you.
I created a table like
tblState has:
1)State_Id(int 4,Identity Increment by 1)
2)CountryName(char 50 Allow Nulls)
3)State_Name(char 50 Allow Nulls)
The code I has is in classic asp.I am posting just to give an idea for you.Hope this helps you.
asp.net Syntax (Toggle Plain Text)
Set Conn = Server.CreateObject("ADODB.Connection") connStr = "Provider=; Driver={SQL Server}; Server=sample; Database=data; DSN=login; UID=vari; PWD=ullet;" Conn.Open(connStr) sql = "" sql = "select * from tblState" Set RS = Conn.Execute(sql) If RS.BOF And RS.EOF Then Error_Msg = "Database Connection Failed. Please contact the systems administrator." Else do until RS.EOF region = RS.Fields("CountryName") commid = cdbl(RS.Fields("State_Id")) comm = RS.Fields("State_Name") if region = region_form then comm_options = comm_options & "<option value=" & commid & " selected>" & trim(comm) & "</option>" else comm_options = comm_options & "<option value=" & commid & ">" & trim(comm) & "</option>" end if RS.movenext loop End If
If you need more briefly let me know i can help you
terry
Last edited by peter_budo; Dec 12th, 2008 at 6:57 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Mac Address in ASP.net using vb.net / Ajax
- Next Thread: Hiding Columns in the datagrid
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax alltypeofvideos appliances application asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class complex control countryselector dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit editing embeddingactivexcontrol feedback fileuploader fill findcontrol flash folder form gridview gudi iis image javascript languages list listbox maps microsoft mobile mouse mssql nameisnotdeclared news novell numerical opera parent problem profile project radio redirect registration relationaldatabases reportemail response.redirect richtextbox rows schoolproject search security select sessionvariables silverlight smoobjects software sql sql-server ssl tracking treeview validatedate validation vb.net videos vista visualstudio vs2008 web webapplications webdevelopment webprogramming wizard xsl





