hi
i have 1-datalist (that use pagination) 2-dropdownlist 3-button=Ibtnselect1 in my page
and these are my table in database
HOuse_info table
Id
|
Behcode
|
Region
|
name
|
1
|
1115
|
1
|
Store1
|
2
|
1116
|
2
|
Store2
|
3
|
1117
|
2
|
Store3
|
4
|
1118
|
5
|
Store4
|
House_p table
Id
|
Behcode
|
Name
|
Description
|
Model
|
1
|
1115
|
Iron
|
Test
|
Q2
|
2
|
1115
|
Vacumcleaner
|
Test2
|
Cv21
|
3
|
1117
|
Carpet
|
Test3
|
Xs23
|
4
|
1116
|
Furniture
|
Test4
|
Df23
|
Region table
Id
|
region
|
1
|
1
|
2
|
2
|
3
|
3
|
4
|
4
|
5
|
5
|
here users product's information are inserted in House_p table and users inforamtion inserted on House_info table
when page is load in my datalist show all product from House_p table
and i bind dropdownlist from region table
here i want when users select their region from dropdown list in datalist show product that are in selected region according to house_info table
now when i select region from dropdown list
EX: i select 1
in my datalist in first page show all product that are in region=1
problem is :when i click on other page of my datalist it showed all product that are in House_p table but i want it showed product that related to my selected item from dropdownlist i means first page is enough i don't want after showing product related
sp
ALTER PROCEDURE [dbo].[GetProducts]
(
@Region tinyint = 0
)
AS
BEGIN
SET NOCOUNT ON;
SELECT distinct House_Info.BehCode,
House_Info.Region,House_p.Name,House_p.Description
,House_p.image,House_p.Date as [Maxdate],House_p.Model
FROM House_Info LEFT OUTER JOIN House_p ON House_Info.Behcode = House_p.Behcode
WHERE ( (LOWER(House_Info.Region) = LOWER(@Region)) OR @Region = 0)
order by [Maxdate] desc
end
Behind code
protected void Ibtnselect1_Click(object sender, ImageClickEventArgs e)
{
SqlCommand _cmd = new SqlCommand("GetProducts", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
if (DDLzone1.SelectedItem.Value != "0")
{
_cmd.Parameters.AddWithValue("@Region", DDLzone1.SelectedItem.Value);
}
_cn.Open();
SqlDataReader _dr = _cmd.ExecuteReader();
if (_dr.HasRows)
{
DataList1.DataSource = _dr;
DataList1.DataBind();
}
_cn.Close();
}
}
best regards