ASP.NET ObjectDatasource SelectParameters CookieParameter 질문
문제
내 쿠키가 다음과 같이 설정되면 : response.cookies ( "직원") ( "userId") = 43
ObjectDatasource SelectParameters CookieParameter 내 에서이 값을 얻으려면 어떻게해야합니까?
<asp:ObjectDataSource ID="odsProducts" runat="server" TypeName="MyCompany.Products" SelectMethod="GetAll">
<SelectParameters>
<asp:CookieParameter CookieName="????" Name="UserID" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
나는 이런 일을해야한다고 가정하고 있습니까?
<asp:ObjectDataSource ID="odsProducts" runat="server" TypeName="MyCompany.Products" SelectMethod="GetAll">
<SelectParameters>
<asp:CookieParameter CookieName="Employees.UserID" Name="UserID" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
해결책
Not ideal, but you could set the ObjectDatasource's Parameter DefaultValue in the code-behind odsProducts.SelectParameters["UserId"].DefaultValue = Response.Cookies["Employees"]["UserID"]
there may be an syntax error in there.
다른 팁
You can create custom control to solve this problem. Kevin Isom's blog has a blog entry.
Custom Parameter for a DataSource
제휴하지 않습니다 StackOverflow