开发者

Bind Session field to System.Data.Linq.Binary

开发者 https://www.devze.com 2023-04-07 12:51 出处:网络
It\'s a picture, an array of bytes which is in the Session. I can\'t seem to bind it to the automatically created model for my table, inside my DataContext. I\'m trying to do so using a FormView and a

It's a picture, an array of bytes which is in the Session. I can't seem to bind it to the automatically created model for my table, inside my DataContext. I'm trying to do so using a FormView and an ObjectDataSource, with a specified type.

Some example code:

<ObjectDataSource [...] DataObjectTypeName="MyTypeName" >

    <UpdateParameters>
        <asp:SessionParameter Name="MyClassPropName" SessionField="MySessionFieldName" />
    </UpdateParameters>

    <InsertParameters>
        <asp:SessionParameter Name="MyClassPropName" SessionField="MySessionFieldName" />
    </开发者_JAVA百科InsertParameters>

</ObjectDataSource>

I've tried specifying some types to the TypeName property directy on the parameter and it didn't work as well.

The problem is that my property specified to be bound to a Session field is always null, with both operations (Insert and Update). And I'm sure my Session field has some value, which in this case, is an array of bytes. Do I have to name the Session Field to the name of my class' Property?

Is this a problem with the Linq.Binary data type or with binding a Session Field to a specified DataObjectTypeName?

Help?


Since I could not bind my business class to the Session Field with Binary nor with byte[], I just changed the property type from Binary to byte[] and did so manually on the Updating and Inserting event of the ObjectDataSource, using the same handler method, like so:

MyBusinessClass foo = (MyBusinessClass)e.InputParameters["BusinessClass"];
foo.Photo = (byte[])Session["MyImage"];
0

精彩评论

暂无评论...
验证码 换一张
取 消