<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:HIbuddyConnectionString %>"
SelectCommand="SELECT ID,owner,PostedBy,Path,PostDate,status,
CASE status
WHEN '0' THEN 'New'
WHEN '1' THEN 'Listened'
WHEN '99' THEN 'Removed'
else ' unknown'
END as StatusName
FROM Tbl_wallpost
WHERE CONVERT (varchar(10), PostDate, 103) >= @dateFrom AND CONVERT (varchar(10), PostDate, 103) <= @dateTo"
UpdateCommand="UPDATE Tbl_wallpost SET status=@status WHERE ID=@ID"
DataSourceMode="DataSet"
FilterExpression="owner='{0}'" EnableCaching="true">
<FilterParameters>
<asp:ControlParameter Name="owner" ControlId="ownerNo" PropertyName="Text"/>
</FilterParameters>
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" Name="dateFrom" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="dateTo" PropertyName="Text" />
</SelectParameters>
我的问题是当我想写FilterExpression =“owner ='{0}'或者PostedBy ='{1}'”时,过滤器显示错误的结果?什么原因?我需要按所有者过滤数据并单独发布.PLz建议。
答案 0 :(得分:0)
FilterExpression="owner='{0}' OR PostedBy='{1}'"
只要您有两个FilterParameters
,就应该有效
<FilterParameters>
<asp:ControlParameter Name="owner" ControlId="ownerNo"
PropertyName="Text" ConvertEmptyStringToNull="true"/>
<asp:ControlParameter Name="PostedBy" ControlId="PostedBy"
PropertyName="Text" ConvertEmptyStringToNull="true"/>
</FilterParameters>
答案 1 :(得分:0)
我已解决了使用以下内容在“Where”语句中创建两个或更多“Like子句”的问题:
Where CHARINDEX(@Par1, Col1)<>0) and ...