hi
this is SerialFilm table
Id
|
Name
|
Genre
|
Finished
|
1
|
Friends
|
Comedy
|
Finished
|
2
|
Breacking bad
|
Action
|
|
|
|
|
|
and in search.aspx page is Dropdown list that I can select Item from it and after click button it will show result in gridview below is SP
ALTER PROCEDURE [dbo].[Film_Information]
@PageIndex INT = 1
,@PageSize INT = 5
,@RecordCount INT OUTPUT
,@Genre nvarchar(100)
,@Daste nvarchar(100)
AS
BEGIN
SET NOCOUNT ON;
SELECT ROW_NUMBER() OVER
(
ORDER BY [Preference]
)AS RowNumber
,id
,Name
,Genre
,Finished
INTO #Results
FROM SerialFilm
WHERE (Name IS NOT NULL)and(Genre=@Genre or @Genre=N'انتخاب ژانر')and(Daste=@Daste or @Daste=N'دسته بندی')and(Finished=@Genre or @Genre=N'انتخاب ژانر')
SELECT @RecordCount = COUNT(*)
FROM #Results
SELECT * FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
DROP TABLE #Results
END
and
private void GetFilmInfo(int pageIndex)
{
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand cmd = General.GetCommand("Film_Information", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
cmd.Parameters.AddWithValue("@PageSize", PageSize);
cmd.Parameters.AddWithValue("@Genre", Ddljanr.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Daste", Ddldaste.SelectedItem.Text);
I want it search @genre (selected Item from dropdownlist) in two columns :
WHERE (Name IS NOT NULL)and(Genre=@Genre or @Genre=N'انتخاب ژانر')and(Daste=@Daste or @Daste=N'دسته بندی')and(Finished=@Genre or @Genre=N'انتخاب ژانر')
but when I click button to show result it doesn't work I mean it doesn't show any thing in gridview but when I delete this code
(Finished=@Genre or @Genre=N'انتخاب ژانر')
it works correctly but I want it search to column when I select Item from Dropdownlist
where is my mistake?
Best regards
neda