在回发期间将字符串添加到列表

时间:2013-01-05 18:28:55

标签: c# asp.net list updatepanel

我有类似的东西......

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显示我想要的内容..(名为Games_GenreList的复选框列表中的所选游戏类型列表。 但是当我添加以下行时 Var_Games_Genres.Add(Genre.Value.ToString()); ///感兴趣的线........ 它不会更改updatepanel上的任何内容。 我也在google chrome的控制台上得到了这个....

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

我真的不知道出了什么问题。 谢谢。

1 个答案:

答案 0 :(得分:0)

尝试

List Var_Games_Genres = new List();
切换案例之前的