DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   Master/Detail DropDownList and DataGrid (http://www.daniweb.com/forums/thread160399.html)

divyasrinivasan Dec 10th, 2008 3:29 am
Re: Master/Detail DropDownList and DataGrid
 
i have two drop downlist wen i select india the partcular states shld come....but my selected index function is different from urs....is it correct

Traicey Dec 10th, 2008 3:31 am
Re: Master/Detail DropDownList and DataGrid
 
Is your DDL filled with each country?

divyasrinivasan Dec 10th, 2008 3:35 am
Re: Master/Detail DropDownList and DataGrid
 
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

divyasrinivasan Dec 10th, 2008 3:36 am
Re: Master/Detail DropDownList and DataGrid
 
ya i got all the countries wic i inserted into ddllcountryname

Traicey Dec 10th, 2008 3:36 am
Re: Master/Detail DropDownList and DataGrid
 
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

divyasrinivasan Dec 10th, 2008 3:38 am
Re: Master/Detail DropDownList and DataGrid
 
its registration form ..i cant keep button na...u find this in many site select country n corresponidng states will come in another dropdownlist...but the code iam not finding

Traicey Dec 10th, 2008 3:42 am
Re: Master/Detail DropDownList and DataGrid
 
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

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

Traicey Dec 10th, 2008 3:50 am
Re: Master/Detail DropDownList and DataGrid
 
I think at the moment u can use that to debug and see whats working and what's not working then after that u can fix ur selectedindexchanged event on DDL

divyasrinivasan Dec 10th, 2008 5:39 am
Re: Master/Detail DropDownList and DataGrid
 
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();
}

Traicey Dec 10th, 2008 5:55 am
Re: Master/Detail DropDownList and DataGrid
 
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);


All times are GMT -4. The time now is 5:18 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC