Friday, April 20, 2012

Set SelectParameter for SqlDataSource SelectCommand with unknown ammount of variables

"



    SelectCommand="SELECT *
FROM Date AS t1 FULL OUTER JOIN (SELECT * FROM WorkHoursEntry WHERE (WorkerID LIKE @WorkerID)) AS t2 ON t1.PKDate = t2.WorkDay
LEFT OUTER JOIN Worker AS t3 ON t2.WorkerID = t3.WorkerID
LEFT OUTER JOIN (SELECT * FROM Project WHERE ProjectID IN(@Project)) AS t4 ON t2.ProjectID = t4.ProjectID"
FilterExpression="YearMonth IN({0})"
>
<FilterParameters>
<asp:ControlParameter ControlID="yearMonthFilterLabel" Name="YearMonth"
PropertyName="Text" Type="String" />
</FilterParameters>
<SelectParameters>
<asp:ControlParameter ControlID="WorkerIDLabel" Name="WorkerID"
PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="projectFilterLabel" Name="Project"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>


Greetings, I have problem with @Project ControlParameter, problem is I don't know how to pass several values and FilterParameters method won't work as I want. Is there any way to pass several variables ? (without using c#).



projectFilterLabel.Text = 'aaa, bbb, ccc';


Basically what I want to do is to select all values from Date table and join them with some values from Project table and output to DataList.



Any help appreciated, I just started learning asp.net



Thanks.





No comments:

Post a Comment