Hi Paul,
I'm thinking that I do indeed can access a custom property in the Page using FormParameter.
Here is the link
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.formparameter.aspxI don't see why if we can use form's textbox, why we can not use the public property the same way. At least I can select the properties when I Configure Data source. So, for the Insert command, do you think I can use it?
>>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?
If it's not broken, fix it until it is.
My Blog