DropDown 未正确过滤 ASCX 控件

发布于 2024-10-17 06:23:43 字数 14694 浏览 2 评论 0原文

我的表单上有一个下拉列表,它应该过滤或显示整个项目或特定迭代的标签云。但这很奇怪,因为当我从列表中选择某些迭代时,我得到了不同的结果。有时ascx控件根本不显示,有时它显示标签云,但它不正确,有时它显示正确的标签云。我不知道为什么会发生这种情况...提前感谢您的帮助!

displaycloud.aspx:

<asp:DropDownList ID="filteroptions" runat="server" onselectedindexchanged="filteroptions_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>   

<asp:UpdatePanel ID="UpdateIteration" runat="server">
<ContentTemplate>                         
   <TagCloud:TagCloudControl ID="TagCloudControl1" runat="server" />  
</ContentTemplate>                 
<Triggers>                     
   <asp:AsyncPostBackTrigger ControlID="filteroptions" />                
</Triggers>  
</asp:UpdatePanel> 

displaycloud.aspx.cs:

protected void Page_Load(object sender, EventArgs e)
{
    proj_name = Request.QueryString["project"].ToString();
    proj_id = Request.QueryString["id"].ToString();

    SqlConnection conn = new SqlConnection(GetConnectionString());
    conn.Open();

    cmd = new SqlCommand("Select CONVERT(VARCHAR(10), StartDate, 103) + ' - ' + CONVERT(VARCHAR(10), EndDate, 103) AS Iteration, ProjectIterationID FROM Iterations WHERE ProjectID = '" + proj_id + "'", conn);

    cmd.CommandType = CommandType.Text;

    SqlDataAdapter da = new SqlDataAdapter(cmd);

    DataSet ds = new DataSet();

    da.Fill(ds);;

    conn.Close();

    if (!Page.IsPostBack)
    {
        filteroptions.DataSource = ds;
        filteroptions.DataTextField = "Iteration";
        filteroptions.DataValueField = "ProjectIterationID";
        filteroptions.DataBind();

        filteroptions.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Entire Project", "0"));

    }
}


protected void filteroptions_SelectedIndexChanged(object sender, EventArgs e)
{

    string selected_iteration = filteroptions.SelectedValue;
    Session["iteration"] = selected_iteration;

}

ASCX CS 文件:

protected void Page_Load(object sender, EventArgs e)
{
    proj_name = Request.QueryString["project"].ToString();
    proj_id = Request.QueryString["id"].ToString();


    if (String.IsNullOrEmpty((string)Session["iteration"]))
    {
        iteration = "0";
    }
    else
    {
        iteration = (string)Session["iteration"];
    }

    BindTagCloud();


}

private void BindTagCloud()
{

    int pro_id = Convert.ToInt32(proj_id);
    int iteration_id = Convert.ToInt32(iteration);

    var tagSummaryNegative = from af in db.AgileFactors
                     join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                     join s in db.Stories on psf.StoryID equals s.StoryID
                     join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                     join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                     join pro in db.Projects on it.ProjectID equals pro.ProjectID
                     where pro.ProjectID == pro_id &&
                           pro.ProjectID == it.ProjectID &&
                           it.ProjectIterationID == pim.ProjectIterationID &&
                           pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 1 &&
                           s.StoryID == psf.StoryID &&
                           psf.AgileFactorID == af.AgileFactorID
                     group af by af.Name into tagGroup

                     select new
                     {

                         Tag = tagGroup.Key,
                         tagCount = tagGroup.Count()

                     };

    var tagSummaryNegativeIteration = from af in db.AgileFactors
                             join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                             join s in db.Stories on psf.StoryID equals s.StoryID
                             join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                             join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                             join pro in db.Projects on it.ProjectID equals pro.ProjectID
                             where pro.ProjectID == pro_id &&
                                   pro.ProjectID == it.ProjectID &&
                                   it.ProjectIterationID == iteration_id &&
                                   it.ProjectIterationID == pim.ProjectIterationID &&
                                   pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 1 &&
                                   s.StoryID == psf.StoryID &&
                                   psf.AgileFactorID == af.AgileFactorID
                             group af by af.Name into tagGroup

                             select new
                             {

                                 Tag = tagGroup.Key,
                                 tagCount = tagGroup.Count()

                             };

    var tagSummaryPositive = from af in db.AgileFactors
                             join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                             join s in db.Stories on psf.StoryID equals s.StoryID
                             join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                             join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                             join pro in db.Projects on it.ProjectID equals pro.ProjectID
                             where pro.ProjectID == pro_id &&
                                   pro.ProjectID == it.ProjectID &&
                                   it.ProjectIterationID == pim.ProjectIterationID &&
                                   pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 0 &&
                                   s.StoryID == psf.StoryID &&
                                   psf.AgileFactorID == af.AgileFactorID
                             group af by af.Name into tagGroup

                             select new
                             {

                                 Tag = tagGroup.Key,
                                 tagCount = tagGroup.Count()

                             };

    var tagSummaryPositiveIteration = from af in db.AgileFactors
                             join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                             join s in db.Stories on psf.StoryID equals s.StoryID
                             join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                             join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                             join pro in db.Projects on it.ProjectID equals pro.ProjectID
                             where pro.ProjectID == pro_id &&
                                   pro.ProjectID == it.ProjectID &&
                                   it.ProjectIterationID == iteration_id &&
                                   it.ProjectIterationID == pim.ProjectIterationID &&
                                   pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 0 &&
                                   s.StoryID == psf.StoryID &&
                                   psf.AgileFactorID == af.AgileFactorID
                             group af by af.Name into tagGroup

                             select new
                             {

                                 Tag = tagGroup.Key,
                                 tagCount = tagGroup.Count()

                             };


    int maxTagFrequencyNegative = (from t in tagSummaryNegative select (int?)t.tagCount).Max() ?? 0;
    int maxTagFrequencyPositive = (from t in tagSummaryPositive select (int?)t.tagCount).Max() ?? 0;

    int maxTagFrequencyNegativeIteration = (from t in tagSummaryNegativeIteration select (int?)t.tagCount).Max() ?? 0;
    int maxTagFrequencyPositiveIteration = (from t in tagSummaryPositiveIteration select (int?)t.tagCount).Max() ?? 0;


    var tagCloudNegative = from af in db.AgileFactors
                   join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                   join s in db.Stories on psf.StoryID equals s.StoryID
                   join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                   join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                   join pro in db.Projects on it.ProjectID equals pro.ProjectID
                   where pro.ProjectID == pro_id &&
                         pro.ProjectID == it.ProjectID &&
                         it.ProjectIterationID == pim.ProjectIterationID &&
                         pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 1 &&
                         s.StoryID == psf.StoryID &&
                         psf.AgileFactorID == af.AgileFactorID
                   group af by af.Name into tagGroup
                   select new
                   {

                       Tag = tagGroup.Key,
                       weight = (double)tagGroup.Count() / maxTagFrequencyNegative * 100
                   };

    var tagCloudNegativeIteration = from af in db.AgileFactors
                           join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                           join s in db.Stories on psf.StoryID equals s.StoryID
                           join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                           join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                           join pro in db.Projects on it.ProjectID equals pro.ProjectID
                           where pro.ProjectID == pro_id &&
                                 pro.ProjectID == it.ProjectID &&
                                 it.ProjectIterationID == iteration_id &&
                                 it.ProjectIterationID == pim.ProjectIterationID &&
                                 pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 1 &&
                                 s.StoryID == psf.StoryID &&
                                 psf.AgileFactorID == af.AgileFactorID
                           group af by af.Name into tagGroup
                           select new
                           {

                               Tag = tagGroup.Key,
                               weight = (double)tagGroup.Count() / maxTagFrequencyNegative * 100
                           };

    var tagCloudPositive = from af in db.AgileFactors
                           join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                           join s in db.Stories on psf.StoryID equals s.StoryID
                           join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                           join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                           join pro in db.Projects on it.ProjectID equals pro.ProjectID
                           where pro.ProjectID == pro_id &&
                                 pro.ProjectID == it.ProjectID &&
                                 it.ProjectIterationID == pim.ProjectIterationID &&
                                 pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 0 &&
                                 s.StoryID == psf.StoryID &&
                                 psf.AgileFactorID == af.AgileFactorID
                           group af by af.Name into tagGroup
                           select new
                           {

                               Tag = tagGroup.Key,
                               weight = (double)tagGroup.Count() / maxTagFrequencyNegative * 100
                           };

    var tagCloudPositiveIteration = from af in db.AgileFactors
                                    join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                                    join s in db.Stories on psf.StoryID equals s.StoryID
                                    join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                                    join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                                    join pro in db.Projects on it.ProjectID equals pro.ProjectID
                                    where pro.ProjectID == pro_id &&
                                          pro.ProjectID == it.ProjectID &&
                                          it.ProjectIterationID == iteration_id &&
                                          it.ProjectIterationID == pim.ProjectIterationID &&
                                          pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 0 &&
                                          s.StoryID == psf.StoryID &&
                                          psf.AgileFactorID == af.AgileFactorID
                                    group af by af.Name into tagGroup
                                    select new
                                    {

                                        Tag = tagGroup.Key,
                                        weight = (double)tagGroup.Count() / maxTagFrequencyNegative * 100
                                    };

    if (iteration_id != 0)
    {
        ListView1.DataSource = tagCloudNegativeIteration;
        ListView1.DataBind();

        ListView2.DataSource = tagCloudPositiveIteration;
        ListView2.DataBind();

    }
    else
    {
        ListView1.DataSource = tagCloudNegative;
        ListView1.DataBind();

        ListView2.DataSource = tagCloudPositive;
        ListView2.DataBind();


    }

}

I have a dropdown list on my form which should filter out or display my tag cloud for an entire project or for a specific iteration. It's strange though, because I get different results when I select certain iterations from the list. Sometimes the ascx control doesn't display at all, sometimes it displays a tag cloud, but it's incorrect, and sometimes it displays the right one. I have no idea why this is happening... Thanks in advance for your help!

displaycloud.aspx:

<asp:DropDownList ID="filteroptions" runat="server" onselectedindexchanged="filteroptions_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>   

<asp:UpdatePanel ID="UpdateIteration" runat="server">
<ContentTemplate>                         
   <TagCloud:TagCloudControl ID="TagCloudControl1" runat="server" />  
</ContentTemplate>                 
<Triggers>                     
   <asp:AsyncPostBackTrigger ControlID="filteroptions" />                
</Triggers>  
</asp:UpdatePanel> 

displaycloud.aspx.cs:

protected void Page_Load(object sender, EventArgs e)
{
    proj_name = Request.QueryString["project"].ToString();
    proj_id = Request.QueryString["id"].ToString();

    SqlConnection conn = new SqlConnection(GetConnectionString());
    conn.Open();

    cmd = new SqlCommand("Select CONVERT(VARCHAR(10), StartDate, 103) + ' - ' + CONVERT(VARCHAR(10), EndDate, 103) AS Iteration, ProjectIterationID FROM Iterations WHERE ProjectID = '" + proj_id + "'", conn);

    cmd.CommandType = CommandType.Text;

    SqlDataAdapter da = new SqlDataAdapter(cmd);

    DataSet ds = new DataSet();

    da.Fill(ds);;

    conn.Close();

    if (!Page.IsPostBack)
    {
        filteroptions.DataSource = ds;
        filteroptions.DataTextField = "Iteration";
        filteroptions.DataValueField = "ProjectIterationID";
        filteroptions.DataBind();

        filteroptions.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Entire Project", "0"));

    }
}


protected void filteroptions_SelectedIndexChanged(object sender, EventArgs e)
{

    string selected_iteration = filteroptions.SelectedValue;
    Session["iteration"] = selected_iteration;

}

ASCX CS FILE:

protected void Page_Load(object sender, EventArgs e)
{
    proj_name = Request.QueryString["project"].ToString();
    proj_id = Request.QueryString["id"].ToString();


    if (String.IsNullOrEmpty((string)Session["iteration"]))
    {
        iteration = "0";
    }
    else
    {
        iteration = (string)Session["iteration"];
    }

    BindTagCloud();


}

private void BindTagCloud()
{

    int pro_id = Convert.ToInt32(proj_id);
    int iteration_id = Convert.ToInt32(iteration);

    var tagSummaryNegative = from af in db.AgileFactors
                     join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                     join s in db.Stories on psf.StoryID equals s.StoryID
                     join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                     join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                     join pro in db.Projects on it.ProjectID equals pro.ProjectID
                     where pro.ProjectID == pro_id &&
                           pro.ProjectID == it.ProjectID &&
                           it.ProjectIterationID == pim.ProjectIterationID &&
                           pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 1 &&
                           s.StoryID == psf.StoryID &&
                           psf.AgileFactorID == af.AgileFactorID
                     group af by af.Name into tagGroup

                     select new
                     {

                         Tag = tagGroup.Key,
                         tagCount = tagGroup.Count()

                     };

    var tagSummaryNegativeIteration = from af in db.AgileFactors
                             join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                             join s in db.Stories on psf.StoryID equals s.StoryID
                             join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                             join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                             join pro in db.Projects on it.ProjectID equals pro.ProjectID
                             where pro.ProjectID == pro_id &&
                                   pro.ProjectID == it.ProjectID &&
                                   it.ProjectIterationID == iteration_id &&
                                   it.ProjectIterationID == pim.ProjectIterationID &&
                                   pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 1 &&
                                   s.StoryID == psf.StoryID &&
                                   psf.AgileFactorID == af.AgileFactorID
                             group af by af.Name into tagGroup

                             select new
                             {

                                 Tag = tagGroup.Key,
                                 tagCount = tagGroup.Count()

                             };

    var tagSummaryPositive = from af in db.AgileFactors
                             join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                             join s in db.Stories on psf.StoryID equals s.StoryID
                             join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                             join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                             join pro in db.Projects on it.ProjectID equals pro.ProjectID
                             where pro.ProjectID == pro_id &&
                                   pro.ProjectID == it.ProjectID &&
                                   it.ProjectIterationID == pim.ProjectIterationID &&
                                   pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 0 &&
                                   s.StoryID == psf.StoryID &&
                                   psf.AgileFactorID == af.AgileFactorID
                             group af by af.Name into tagGroup

                             select new
                             {

                                 Tag = tagGroup.Key,
                                 tagCount = tagGroup.Count()

                             };

    var tagSummaryPositiveIteration = from af in db.AgileFactors
                             join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                             join s in db.Stories on psf.StoryID equals s.StoryID
                             join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                             join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                             join pro in db.Projects on it.ProjectID equals pro.ProjectID
                             where pro.ProjectID == pro_id &&
                                   pro.ProjectID == it.ProjectID &&
                                   it.ProjectIterationID == iteration_id &&
                                   it.ProjectIterationID == pim.ProjectIterationID &&
                                   pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 0 &&
                                   s.StoryID == psf.StoryID &&
                                   psf.AgileFactorID == af.AgileFactorID
                             group af by af.Name into tagGroup

                             select new
                             {

                                 Tag = tagGroup.Key,
                                 tagCount = tagGroup.Count()

                             };


    int maxTagFrequencyNegative = (from t in tagSummaryNegative select (int?)t.tagCount).Max() ?? 0;
    int maxTagFrequencyPositive = (from t in tagSummaryPositive select (int?)t.tagCount).Max() ?? 0;

    int maxTagFrequencyNegativeIteration = (from t in tagSummaryNegativeIteration select (int?)t.tagCount).Max() ?? 0;
    int maxTagFrequencyPositiveIteration = (from t in tagSummaryPositiveIteration select (int?)t.tagCount).Max() ?? 0;


    var tagCloudNegative = from af in db.AgileFactors
                   join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                   join s in db.Stories on psf.StoryID equals s.StoryID
                   join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                   join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                   join pro in db.Projects on it.ProjectID equals pro.ProjectID
                   where pro.ProjectID == pro_id &&
                         pro.ProjectID == it.ProjectID &&
                         it.ProjectIterationID == pim.ProjectIterationID &&
                         pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 1 &&
                         s.StoryID == psf.StoryID &&
                         psf.AgileFactorID == af.AgileFactorID
                   group af by af.Name into tagGroup
                   select new
                   {

                       Tag = tagGroup.Key,
                       weight = (double)tagGroup.Count() / maxTagFrequencyNegative * 100
                   };

    var tagCloudNegativeIteration = from af in db.AgileFactors
                           join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                           join s in db.Stories on psf.StoryID equals s.StoryID
                           join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                           join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                           join pro in db.Projects on it.ProjectID equals pro.ProjectID
                           where pro.ProjectID == pro_id &&
                                 pro.ProjectID == it.ProjectID &&
                                 it.ProjectIterationID == iteration_id &&
                                 it.ProjectIterationID == pim.ProjectIterationID &&
                                 pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 1 &&
                                 s.StoryID == psf.StoryID &&
                                 psf.AgileFactorID == af.AgileFactorID
                           group af by af.Name into tagGroup
                           select new
                           {

                               Tag = tagGroup.Key,
                               weight = (double)tagGroup.Count() / maxTagFrequencyNegative * 100
                           };

    var tagCloudPositive = from af in db.AgileFactors
                           join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                           join s in db.Stories on psf.StoryID equals s.StoryID
                           join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                           join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                           join pro in db.Projects on it.ProjectID equals pro.ProjectID
                           where pro.ProjectID == pro_id &&
                                 pro.ProjectID == it.ProjectID &&
                                 it.ProjectIterationID == pim.ProjectIterationID &&
                                 pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 0 &&
                                 s.StoryID == psf.StoryID &&
                                 psf.AgileFactorID == af.AgileFactorID
                           group af by af.Name into tagGroup
                           select new
                           {

                               Tag = tagGroup.Key,
                               weight = (double)tagGroup.Count() / maxTagFrequencyNegative * 100
                           };

    var tagCloudPositiveIteration = from af in db.AgileFactors
                                    join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
                                    join s in db.Stories on psf.StoryID equals s.StoryID
                                    join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
                                    join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
                                    join pro in db.Projects on it.ProjectID equals pro.ProjectID
                                    where pro.ProjectID == pro_id &&
                                          pro.ProjectID == it.ProjectID &&
                                          it.ProjectIterationID == iteration_id &&
                                          it.ProjectIterationID == pim.ProjectIterationID &&
                                          pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 0 &&
                                          s.StoryID == psf.StoryID &&
                                          psf.AgileFactorID == af.AgileFactorID
                                    group af by af.Name into tagGroup
                                    select new
                                    {

                                        Tag = tagGroup.Key,
                                        weight = (double)tagGroup.Count() / maxTagFrequencyNegative * 100
                                    };

    if (iteration_id != 0)
    {
        ListView1.DataSource = tagCloudNegativeIteration;
        ListView1.DataBind();

        ListView2.DataSource = tagCloudPositiveIteration;
        ListView2.DataBind();

    }
    else
    {
        ListView1.DataSource = tagCloudNegative;
        ListView1.DataBind();

        ListView2.DataSource = tagCloudPositive;
        ListView2.DataBind();


    }

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绮筵 2024-10-24 06:23:43

据我了解,您使用 filteroptions_SelectedIndexChanged 方法将选定的迭代放入会话中。然后使用标签云控件上的会话值来绑定正确的数据。然而,事件处理程序是在页面和控件的加载事件之后执行的。我建议您在稍后的某个时间点绑定标签云(例如Page_PreRender)。

编辑:
我认为您应该使用以下代码片段替换 ASCX.CS 文件中的 Page_Load 方法:

    protected void Page_Load(object sender, EventArgs e)
    {
        proj_name = Request.QueryString["project"].ToString();
        proj_id = Request.QueryString["id"].ToString();
    }

    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty((string)Session["iteration"]))
        {
            iteration = "0";
        }
        else
        {
            iteration = (string)Session["iteration"];
        }

        BindTagCloud();
    }

As I understood you use filteroptions_SelectedIndexChanged method to put selected iteration into session. And then use value from session on tag cloud control to bind correct data. However event handlers are executed after page's and control's load events. I suggest you binding tag cloud at some later point of time (Page_PreRender for instance).

Edit:
I think you should replace your Page_Load method in the ASCX.CS file with following snippet:

    protected void Page_Load(object sender, EventArgs e)
    {
        proj_name = Request.QueryString["project"].ToString();
        proj_id = Request.QueryString["id"].ToString();
    }

    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty((string)Session["iteration"]))
        {
            iteration = "0";
        }
        else
        {
            iteration = (string)Session["iteration"];
        }

        BindTagCloud();
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文