(using listbox) I'm using those data to pull data from database
(values in session is used in WHERE statement)
I'm not quite sure how to retrieve data from session value
so that I can use it in sql statement.
Can you help me? I'm posting code and display page code
Session["genderList"] = genderList.Text;
Session["hairList"] = hairList.Text;
Session["eyeList"] = eyeList.Text;
List<ListItem> selectedItems = new List<ListItem>();
foreach (ListItem item in this.state.Items)
{
if (item.Selected) selectedItems.Add(item);
}
Session.Add("state", selectedItems);
Response.Redirect("search_result.aspx");
Below code is for display page (Just the sql code)
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnection %>"
SelectCommand="SELECT [FirstName], [LastName],[Age], [Gender],[HairColor], [EyeColor], [State] FROM TalentRegistration WHERE
ISNULL([Gender],'') = COALESCE(nullif(@Gender,''),Gender,'')
AND ISNULL([HairColor],'') = COALESCE(nullif(@HairColor,''),hairColor,'')
AND ISNULL([EyeColor],'') = COALESCE(nullif(@EyeColor,''),EyeColor,'')
AND
( ISNULL([State],'') in( @State1, coalesce(nullif(@State1,'')))
)
">
<SelectParameters>
<asp:SessionParameter Name="Gender" SessionField="genderList"
ConvertEmptyStringToNull="False" Type="Empty" />
<asp:SessionParameter Name="HairColor" SessionField="hairList"
ConvertEmptyStringToNull="False" Type="Empty" />
<asp:SessionParameter Name="EyeColor" SessionField="eyeList"
ConvertEmptyStringToNull="False" Type="Empty" />
<asp:SessionParameter Name="State" SessionField="state"
ConvertEmptyStringToNull="False" Type="Empty" />
</SelectParameters>
This post has been edited by kmc10314: 21 September 2010 - 11:07 AM

New Topic/Question
Reply




MultiQuote




|