Updatepanel Repeater LinkBut​​ton OnClick绑定ListView

时间:2011-06-13 20:16:25

标签: asp.net user-controls updatepanel

我得到了完整的回发 - 我在转发器中有一个链接按钮并且onclick我想绑定一个列表视图。

两者都在同一个更新面板中。

这是一个usercontrol而不是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 个答案:

答案 0 :(得分:0)

我有两个脚本管理器在运行 - 一个在母版页上......

答案 1 :(得分:0)

我最近遇到了同样的问题:更新面板内部转发器内部的链接按钮。我找到了两个解决方案,用于在单击linkbutton时执行异步回发  1.将以下属性添加到包含转发器和&amp ;;的页面指令中。 linkbutton:

<%@ page ClientIDMode="AutoID" %>
 2.在databind事件上使用ScriptManager作为转发器:

LinkButton linkButton = e.Item.FindControl("button") as LinkButton; ScriptManager.RegisterAsyncPostBackControl(linkButton)