Updatepanel Repeater LinkBut​​ton OnClick绑定ListView

问题描述

|| 我得到了完整的回发-我在转发器中有一个linkbutton,而我想绑定一个listview。 两者都在同一个updatepanel中。 这是一个用户控件,而不是aspx页面
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using umbraco.Linq.Core;
using System.Web.UI.HtmlControls;

using TechReady;

public partial class usercontrols_Videogallery : System.Web.UI.UserControl
{
    public TechReadyDataContextDataContext techDataContext;

    protected void Page_Load(object sender,EventArgs e)
    {      
            Bind_Tracks();
    }

    protected void Bind_Tracks()
    {
        techDataContext = new TechReadyDataContextDataContext();
        var tracks = from t in techDataContext.Tracks
                     orderby t.Title
                     select t;
        TracksListRepeater.DataSource = tracks;
        TracksListRepeater.DataBind();
        techDataContext.dispose();
    }

    protected void Bind_Videogallery(string tracktitle)
    {
        techDataContext = new TechReadyDataContextDataContext();
        var sessions = (from s in techDataContext.Sessions
                        where s.SessionTrack == tracktitle                      
                        orderby s.SessionTrack
                        select s);
        VidgalListView.DataSource = sessions;
        VidgalListView.DataBind();
        techDataContext.dispose();
    }

    protected void TabLink_Click(Object sender,EventArgs e)
    {
           LinkButton lb = (LinkButton)sender;
            RepeaterItem ri = (RepeaterItem)lb.NamingContainer;
            HtmlGenericControl litostyle2 = (HtmlGenericControl)ri.FindControl(\"tablinkli\");
            litostyle2.Attributes.Add(\"Class\",\"ui-tabs-selected\");
            Bind_Videogallery(lb.CommandArgument);
    }

    protected void TracksListRepeater_ItemDataBound(object sender,RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            LinkButton lb = (LinkButton)e.Item.FindControl(\"tablink\");
            ScriptManager1.RegisterasyncPostBackControl(lb);            
        }

    }

    protected void TracksListRepeater_itemcommand(object sender,RepeaterCommandEventArgs e)
    {
        if (e.CommandName == \"TabClicked\")
        {


        }
    }
}
    

解决方法

        我有2个脚本管理器正在运行-一个在主页上...     ,        最近,我遇到了同样的问题:更新面板内部的中继器内部的链接按钮。当单击linkbutton时,我发现了两种执行异步回发的解决方案。  1.将以下属性添加到包含转发器和链接按钮的页面指令中:
<%@ page ClientIDMode=\"AutoID\" %>
 2.在转发器的databind事件上使用ScriptManager:
LinkButton linkButton = e.Item.FindControl(\"button\") as LinkButton;
ScriptManager.RegisterAsyncPostBackControl(linkButton)