I've got a page with a gridview that should display many 'Warranty's via a linq query, or if there is a particular 'Warranty' in my session variable then i want to only show that. The way i'd hoped to achieve this is with the following:
Unfortunately, if the session variable contains my warranty the gridview displays nothing, even though i've checked e.result and it does get assigned.Code:protected void ldsWarrantySearch_Selecting(object sender, LinqDataSourceSelectEventArgs e) { if (Session["Warranty"] != null) { List<Warranty> W = new List<Warranty>(); W.Add(Session["Warranty"] as Warranty); e.Result = W; } else { var Records = from W in DC.Warranties where (W.Postcode == txtWarrantyPostCode.Text || string.IsNullOrEmpty(txtWarrantyPostCode.Text)) && (W.PolicyId.Value.ToString() == txtWarrantyPolicyId.Text || W.MainProductWarrantyId.Value.ToString() == txtWarrantyPolicyId.Text || string.IsNullOrEmpty(txtWarrantyPolicyId.Text)) && (W.CustomerName.Contains(txtWarrantyName.Text) || string.IsNullOrEmpty(txtWarrantyName.Text)) && (W.Address.Contains(txtWarrantyAddress.Text) || string.IsNullOrEmpty(txtWarrantyAddress.Text)) select W; e.Result = Records; } }
I've also tried assigning just the warranty instance (not in a list) and that doesn't work either.
Any suggestions welcome!
Cheers.



Reply With Quote