在我的網頁,我需要搜索名稱,類型容器和斑點和上次更改天青IListBlobItem Oftype CloudBlob LINQ的更改列表<CloudBlob>
var selectedValue = ddlFileType.SelectedValue;
AzureSettings container = AzureSettingsServices.Select(selectedValue.ParseInt(-1));
if (ViewState[container.Name] == null)
{
IEnumerable<IListBlobItem> blobList = BlobHelper.GetFileListByContainer(container.Name);
//I add the viewstate for not spending money in azure :)
ViewState.Add(container.Name, blobList);
}
List<CloudBlob> list = null;
string fileName = txtFileName.Text;
if (!string.IsNullOrWhiteSpace(fileName))
{
//by name and date
list = ((IEnumerable<IListBlobItem>)ViewState[container.Name]).OfType<CloudBlob>().Where(x => x.Name == fileName && x.Properties.LastModified >= dtDate.ValueRange.StartDate && x.Properties.LastModified <= dtDate.ValueRange.EndDate).ToList();
}
else if (string.IsNullOrWhiteSpace(fileName))
{
//by date
list = ((IEnumerable<IListBlobItem>)ViewState[container.Name]).OfType<CloudBlob>().Where(x => x.Properties.LastModified >= dtDate.ValueRange.StartDate && x.Properties.LastModified <= dtDate.ValueRange.EndDate).ToList();
}
if (list != null)
{
// by type
list=list.OfType<CloudBlob>().Where(x => x.Name.Contains(selectedValue)).ToList();
SelectedContainer = container.Name;
grdFiles.DataSource = list;
grdFiles.DataBind();
}
的問題是我不能給列表< CloudBlob>列表,gridview的數據源這是正常的,但我怎麼能設置到名單< CloudBlob>列表中( IEnumerable的< IListBlobItem> bloblist或在我的視圖狀態(注:在我的視圖狀態是我Ilistblobitem名單))回我的gridview的數據源
UPDATE ERROR 2:
grdFiles.DataSource =((IEnumerable的)的ViewState [container.Name]);
grdFiles.DataBind();
下面是有關該錯誤,
'Microsoft.WindowsAzure.Storage,版本= 7.2.1.0,文化=中性公鑰= 31bf3856ad364e35'「Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility + d__0`1 [[Microsoft.WindowsAzure.Storage.Blob.IListBlobItem,Microsoft.WindowsAzure.Storage,版本= 7.2.1.0,文化=中性公鑰= 31bf3856ad364e35]]」
> [SerializationException: 'Microsoft.WindowsAzure.Storage, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Derlemesindeki 'Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility+<LazyEnumerable>d__0`1[[Microsoft.WindowsAzure.Storage.Blob.IListBlobItem, Microsoft.WindowsAzure.Storage, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]' ]
系統。 Runtime.Serializatio n.FormatterServices.InternalGetSerializableMembers(RuntimeType型)12207601個 System.Runtime.Serialization.FormatterServices.GetSerializableMembers(類型類型,的StreamingContext上下文)230 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()143
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(對象OBJ,ISurrogateSelector surrogateSelector,的StreamingContext上下文,serObjectInfoInit serObjectInfoInit,IFormatterConverter來轉換器,objectWriter objectWriter,SerializationBinder粘合劑)178 System.Runtime.Serialization.Formatters.Binary。 WriteObjectInfo.Serialize(Object obj,ISurrogateSelector surrogateSelector,StreamingContext上下文,SerObjectInfoInit serObjectInfoInit,IFormatterConverter轉換器,Objec tWriter objectWriter,SerializationBinder聯編程序)+512 System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph,Header [] inHeaders,__BinaryWriter serWriter,Boolean fCheck)+540 System.Runtime.Serialization.Formatters.Binary。 BinaryFormatter.Serialize(Stream serializationStream,Object graph,Header [] headers,Boolean fCheck)+13 System.Web.UI。System.Web.UI.Serialize.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream,Object graph)+17 System.Web.UI。 ObjectStateFormatter.SerializeValue(SerializerBinaryWriter作家,對象的值)3046
[ArgumentException的: 'Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility + d__0
1[[Microsoft.WindowsAzure.Storage.Blob.IListBlobItem, Microsoft.WindowsAzure.Storage, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]' türündeki 'Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility+<LazyEnumerable>d__0
1 [Microsoft.WindowsAzure.Storage.Blob.IListBlobItem]' 去erini斯里健壯getirmehatası。] System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter作家,對象的值)3770 System.Web.UI.ObjectStateFormatter.Serialize(流的OutputStream,對象stateGraph)144 的System.Web。 UI.ObjectStateFormatter.Serialize(對象狀態圖,目的用途)+71 System.Web.UI。ObjectStateFormatter.System.Web.UI.IStateFormatter.Serialize(Object state)+39 System.Web.UI.Util.SerializeWithAssert(IStateFormatter formatter,Object stateGraph)+37 System.Web.UI.Control.EstimateStateSize(Object state) +45 System.Web.UI.Control.BuildProfileTree(String parentId,Boolean calcViewState)+71 System.Web.UI.Page.BuildPageProfileTree(Boolean enableViewState)+42 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint ,布爾includeStagesAfterAsyncPoint)+5761
我發現錯誤,IEnumerable的無法添加到視圖狀態 –