Updatepanel Repeater LinkButton OnClick Bind ListView
I get full postbacks - I have a linkbutton in a repeater and onclick I want to bind a listview.
Both are in the same updatepanel.
This is a usercontrol not an aspx page.
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")
{
}
}
}
I recently came across this same issue: a linkbutton inside of a repeater inside of an update panel. I found two solutions for performing an asynchronous post back when then linkbutton is clicked.
1. Add the following attribute to the page directive containing the repeater & linkbutton:
<%@ page ClientIDMode="AutoID" %>
2. Use the ScriptManager on the databind event for the repeater:
LinkButton linkButton = e.Item.FindControl("button") as LinkButton;
ScriptManager.RegisterAsyncPostBackControl(linkButton)
I had 2 scriptmanagers running - one on a master page...
精彩评论