我在标记页面和后端方法“ LoadUpdatePanels”中具有以下代码片段,以获取XML数据。
问题在于,由于XML尚未就绪,将异步加载,因此呈现UpdatePanel时会引发空引用错误。
我试图隐藏/显示它不起作用的UpdatePanel。
private void LibraryAddBoxFilters()
{
//create list of songs that match checked boxes
using (var db = new TalLocalDbEntities())
{
//get filtered box with min number of tracks
var id = db.TableBoxNames.Where(a => a.Filter == true).Min(a => a.Tracks);
//get all songs from filtered box with min number of tracks
var myResult = from b in db.TableBoxNames //get boxes
join n in db.TableBoxSongs on b.ID equals n.BoxID //connect box id to boxid
where b.ID == id //select filtered box
select n //retrieve TableBoxSong
;
//for each Filter box selected
foreach (var p in db.TableBoxNames.Where(a => a.Filter == true))
{
if (p.ID != id)//if not first table
//filter boxsongs
myResult.Intersect(from b in db.TableBoxNames //get boxes
where b.ID == p.ID //select filtered box
join n in db.TableBoxSongs on b.ID equals n.BoxID //connect box id to boxid
select n); //retrieve TableBoxSong
}
//convert boxsongs to songs and send to library
prog.CtrlMusicLibrary.matchfilter_Songs = (from m in myResult
join s in db.TableSongs on m.SongID equals s.ID
select s).Distinct().ToList();
}
}