Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using form's property as opposed to Profile property
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01318572
Message ID:
01318736
Views:
14
This message has been marked as the solution to the initial question of the thread.
>Hi everybody,
>
>Do you know the best way of accessing some form properties rather than Profile properties?
>
>Here is what I have in the Form's .cs code
>
>
>public partial class Coordinator_People_Registration_FC : System.Web.UI.Page
>{
>    public int SiteID
>    {
>        get { return Profile.SiteID ; }
>        set { this.SiteID = value; }
>    }
>
>And this is in ASPX:
>
>
><asp:SqlDataSource ID="GradesDataSource" ConnectionString="< %$ ConnectionStrings:FCCMSConnectionString % >"
>SelectCommand="SELECT Grade FROM Grades WHERE SiteID=@SiteID"
>                runat="server">
>                <SelectParameters>
>       < %--             <asp:ProfileParameter Name="SiteID" PropertyName="SiteID" />--% >
>  <asp:FormParameter Name="SiteID" FormField="SiteID" Type = "Int32" />
>                </SelectParameters>
>            </asp:SqlDataSource>
>
>However, using this FormField as a parameter doesn't seem to work.

It's not going to work - you're using the ProfileParameter class, which, oddly enough, expects it's value to come from a profile property. There are a few other classes available (you'll see them in intellisense if you position the cursor between the < SelectParameters sections and type < . - Like CookieParameter, FormParameter, QueryStringParameter, etc. However, there isn't a parameter type that accepts a form property.

There is a generic Parameter class that could be used instead, you might be able to do something like:
<SelectParameters>
   <asp:Parameter Name="SiteID" DefaultValue="<%=this.SiteID %>" />
</SelectParameters>
(that actually might not work, I don't handle any of my data access stuff this way and I haven't tested the above).

You could also just subclass the Parameter class and write code to do what you want.

I'm not sure you'll end up seeing much (any?) of a performance difference from using the ProfileParameter directly - I thought Profile properties were cached on each hit already. Are you seeing something different?
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform