I currently have a LinqDataSource on an ASP.NET page which is used as the data source for a FormView. I need to dynamically alter the where
clause based on para
Please try url decode Request.QueryString[key]
Example:
HttpUtility.UrlDecode(Request.QueryString[key]);
I have finally managed to get this figured out. Thanks to a class from this post, I am able to to use the LinqDataSource_Selecting event and filter my data successfully with wildcards working using this code:
protected void ldsData_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
var result = db.INSTRUMENT_LOOP_DESCRIPTIONs.AsQueryable();
foreach (string key in Request.QueryString.Keys)
{
if (Request.QueryString[key].Trim() != "")
{
result = result.WhereLike(key, Request.QueryString[key].Replace("?", "_").Replace("*", "%"));
}
}
e.Result = result;
}