Last post Jan 03, 2011 07:27 PM by tinac99
Dec 27, 2010 05:43 PM|tinac99|LINK
I have a tables structure all of which has fields InactiveBy(the user who logically deleted a record) and InactiveDate(when it was deleted).
In the list.aspx page template, both the active and inactive records are still being displayed on the screen.
Does anyone have a way such that only those Active(InactiveBy == null) will be displayed?
Thanks for your help!
Dec 27, 2010 09:06 PM|cheah85|LINK
Where InactiveBy is not null
Dec 27, 2010 11:18 PM|gprasadholla|LINK
What datasource you are using? You can always write where clause using either datsource where attribute, or using WhereParamerter
see this..http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.entitydatasource.where.aspx or
Dec 28, 2010 11:29 AM|tinac99|LINK
OK. I am using LinqtoSql datasource. I was hoping to do it in a generic way such that I don't have to create a List.aspx for each page.
Dec 28, 2010 11:55 AM|sjnaughton|LINK
Hi Tinac99, if all your table have said field then in DD4 you can add a custom filter to the QueryExtender in the page, if you are using DD1 then you can do the same by adding a where paremeter to the LinqDataSource.
Dynamic Data 4
Dec 30, 2010 06:11 PM|tinac99|LINK
Please elaborate more on the custom filter. Is it supposed to call a function on the code-behind?
I found the script below as a sample, but I don't know how can I make it to a generic table in the FilterProducts():
<asp:QueryExtender ID="QueryExtender1" runat="server" TargetControlID="LinqDataSource1">
class _Default : System.Web.UI.Page
protected void FilterProducts(object sender, CustomExpressionEventArgs e)
e.Query = from p
where p.ListPrice >= 3500
Dec 30, 2010 10:40 PM|gprasadholla|LINK
You cant make it generic till all your tables are genric. I have a field called status in my all tables. So my following expression works fine for me.
<asp:LinqDataSource ............. Where="Status==1"></asp:LinqDataSource>
Dec 31, 2010 04:30 PM|sjnaughton|LINK
Hi Tinac99, I have done further reasearch and this is not possible with EF but may be possible with L2S. for a generic approach then adding a where parameter to the select parameters will do it for you.
Jan 03, 2011 07:27 PM|tinac99|LINK
I appreciate all your help!
Gprasadholla's way worked it for me.