How can I store a byte[] list in viewstate?

2019-07-31 14:07发布

I want to store some byte[] to ViewState. For example I want to store a list of FileBytes. How can I do it?

1条回答
迷人小祖宗
2楼-- · 2019-07-31 14:32

I haven't actually tried this with a list, but it should be pretty simple:

List<byte> myByteList;
// do something here to load list
ViewState["Bytes"] = myByteList

When you need to get it out:

List<byte> myByteList = (List<byte>)ViewState["Bytes"];

Edit: Changed from byte[] to List.

查看更多
登录 后发表回答