2013-01-05 71 views
1

我有这样的事情中列出....添加字符串回传

switch (PostBackControlParentId) 
      { 
       case "": 
        SearchResults.InnerText = "Sorry. There was an Error."; 
        break; 
       case "GamesTabUpdatePanel": 
        Var_Games_Platform = PlatformDropdown.SelectedValue; 
        Var_Games_Rating = Convert.ToDecimal(Games_RatingTextBox.Text); 
        Var_Games_Developer = DeveloperDropdown.SelectedValue; 
        Var_Games_Publisher = PublisherDropdown.SelectedValue; 
        Var_Games_Year = Convert.ToInt16(YearDropdown.SelectedItem.Value); 
        if (Games_OnlyAvailableCheckBox.Checked) 
        { 
         Var_Games_AvailableOnly = true; 
        } 

        foreach (ListItem Genre in Games_GenreList.Items) 
        { 
         if (Genre.Selected) 
         { 
          SearchResults.InnerText = SearchResults.InnerText + Genre.ToString(); 
          Var_Games_Genres.Add(Genre.Value.ToString());**///The line of interest........** 
         } 
        } 
        //Get Query Data.. 
        //Pass to SQL 
        //Get DataSet 
        //WriteStuff. 
        break; 
       case "MoviesTabUpdatePanel": 
        break; 
       case "EpisodesTabUpdatePanel": 
        break; 
       case "TVShowsTabUpdatePanel": 
        break; 
      } 

现在,当我不做

Var_Games_Genres.Add(Genre.Value。的ToString()); ///关注行........

UpdatePanel的显示正是我想要的。(在CheckBoxList的选择的游戏流派的列表命名Games_GenreList。 但当我添加以下行 Var_Games_Genres.Add(Genre.Value.ToString()); ///感兴趣的线........ 它不会更改任何更新面板上的内容 而且我也得到了这个谷歌浏览器的控制台....

Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object. ScriptResource.axd:847 
Error$create ScriptResource.axd:847 
PageRequestManager$_createPageRequestManagerServerError ScriptResource.axd:766 
PageRequestManager$_parseDelta ScriptResource.axd:1653 
PageRequestManager$_onFormSubmitCompleted ScriptResource.axd:1414 
(anonymous function) ScriptResource.axd:628 
(anonymous function) ScriptResource.axd:4338 
raise ScriptResource.axd:7429 
WebRequest$completed ScriptResource.axd:7433 
XMLHttpExecutor._onReadyStateChange ScriptResource.axd:6857 

我真的不知道发生了什么事情是错误的。 谢谢。

+0

请尝试刷新你的更新面板 –

+0

我试过Updatepanel.update(); 但没用。 –

+0

请检查Var_Games_Genres是否有实例,这意味着您是否使用List创建了它Var_Games_Genres = new List(); –

回答

0

尝试

List Var_Games_Genres = new List(); 

开关罩之前

+0

是的。修复它。谢谢。 –

+0

他可能没有足够的积分来upvote – MethodMan