Hi
I have dropdownlist in my page that bind it from database
BindDropDownList1(DDLzone1, "Guidregion", "Regionname","id");
private void BindDropDownList1(DropDownList DDL, string SPname, string datatextfield, string dataValueField)
{
SqlCommand _cmd = new SqlCommand(SPname, _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();
SqlDataReader _dr = _cmd.ExecuteReader();
if (_dr.HasRows)
{
DDL.DataSource = _dr;
DDL.DataTextField = datatextfield;
DDL.DataValueField = dataValueField;
DDL.DataBind();
}
_cn.Close();
}
SP
ALTER procedure [dbo].[Guidregion]
as
begin
select Regionname,ID
from Region
order by Regionname asc
end
Below is my tables
Region table
id
|
regionname
|
cityid
|
1
|
1
|
Itally
|
2
|
2
|
Itally
|
3
|
3
|
Itally
|
4
|
1
|
India
|
5
|
2
|
India
|
6
|
1
|
USA
|
7
|
2
|
USA
|
8
|
3
|
USA
|
House_info table
id
|
Name
|
City
|
Behcode
|
1
|
Sara
|
Itally
|
4444
|
2
|
Jack
|
USA
|
1111
|
in dropdownlist show all data from region table from regionname column
11122233
now I want it show data from regioncolumn that city is in House_info table so I change SP like below
ALTER procedure [dbo].[GuidregionE]
@Behcode nvarchar(10)
as
begin
Declare @City nvarchar(30)
set @City =(select city from House_info where behcode=@Behcode )
select distinct Regionname,ID
from Region
where CityId=@City
order by Regionname asc
end
and
string data = Server.UrlDecode(Request.QueryString["BehCode"]);
now I don't know How I can define for dropdownlist that it replace @Behcode in SP with above code
How I can do it?
Best Regards
Neda