Nov 13, 2014, 1:18 PM
[CLOSED] LinqDataSource combining columns/aliasing
I would like define a column value based on two other columns. I could perform the following option:
What I really want is:?
In TSQL the query would look like:
I have the ListFilter set up correctly. I just can't build the string that I want to use.
Any thoughts?
<asp:LinqDataSource ID="LDS" runat="server" ContextTypeName="MyContext"
TableName="Categories"
Select="new #RequestCatId, RequestCatAbbr, RequestCatAbbr + " (" + IsActive + ")" as RequestCatAbbrNew, IsActive#
OrderBy="IsActive desc, RequestCatAbbr" />
This would provide results like:- Baseline (true)
- Research (true)
- Archived Documents (false)
What I really want is:?
- Baseline
- Research
- Archived Documents (Inactive)
In TSQL the query would look like:
select RequestCatId, RequestCatAbbr,
RequestCatAbbrNew = CASE IsActive when 0 then RequestCatAbbr + ' (Inactive)' when 1 then RequestCatAbbr END,
IsActive
from Categories
order by IsActive desc, RequestCatAbbr
I could also perform a Union in SQL:select RequestCatId, RequestCatAbbr, RequestCatAbbr as RequestCatAbbrNew, IsActive
from Categories
where IsActive = 1
UNION
select RequestCatId, RequestCatAbbr, RequestCatAbbr + ' (Inactive)' as RequestCatAbbrNew, IsActive
from Categories
where IsActive = 0
order by IsActive desc, RequestCatAbbr
The question above eventually gets me to the following design. I have a GridPanel that shows the RequestCatAbbr dataIndex. I have added a ListFilter on the dataIndex RequestCatAbbr. I would like the ListFilter labels (LabelField) to be readable and thus use the RequestCatAbbrNew while the IDField will be the raw data RequestCatAbbr.I have the ListFilter set up correctly. I just can't build the string that I want to use.
Any thoughts?
Last edited by Daniil; Nov 14, 2014 at 7:45 PM.
Reason: [CLOSED]