Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Repeater not triggering DataBinding event from IAsyncResult callback method

$
0
0

I'm trying to update an asp repeater from a REST call.  My web request has a callback method that binds the results to the repeater.  When I do bind the data the repeater doens't update nor do the repeater events fire.  Here is my code to provide some context.

Thanks for any help in advance.

<asp:UpdatePanel runat="server" ID="connectFeedUP" UpdateMode="Conditional"><Triggers><asp:AsyncPostBackTrigger ControlID="rptConnectFeed" /></Triggers><ContentTemplate><asp:Repeater runat="server" ID="rptConnectFeed" OnItemDataBound="rptConnectFeed_OnItemBound" ><HeaderTemplate><ul class="ConnectStoryArea"></HeaderTemplate><ItemTemplate><li class="ConnectStory"><div class="ConnectStoryTitle"><a href="<%# Eval("URL")%>"><%# Eval("Subject")%></a></div><div class="ConnectStoryContentInfoArea"><div class="ConnectStoryAuthor"><%# Eval("Author")%></div><div class="ConnectStoryDate"><%# Eval("Date")%></div></div><div class="ConnectStoryContent"><%# Eval("Content") %></div></li></ItemTemplate><FooterTemplate></ul></FooterTemplate></asp:Repeater></ContentTemplate></asp:UpdatePanel>

private void DiscussionWebCall()
{
    Uri address = new Uri("https://domain.com");

    HttpWebRequest request = (WebRequest.Create(address)) as HttpWebRequest;
    NetworkCredential netCreds = new NetworkCredential("xxxxxxx", "xxxxx");

    if (netCreds != null)
    {
        string authInfo = ((netCreds.Domain != null) && (netCreds.Domain.Length > 0) ? netCreds.Domain + @"\" : string.Empty) +
         netCreds.UserName + ":" + netCreds.Password;
         authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
         request.Headers["Authorization"] = "Basic " + authInfo;
    }
    request.BeginGetResponse(ResponseCallback, request);
}

private void ResponseCallback(IAsyncResult ar)
{
    var request = (HttpWebRequest)ar.AsyncState;
    var response = request.EndGetResponse(ar);
    IEnumerable<ConnectDiscussion> discussions;

    using (var stream = response.GetResponseStream())
    using (var reader = new StreamReader(stream))
    {
        var contents = reader.ReadToEnd();
        string json = contents.Remove(0, contents.IndexOf('{'));

        JObject jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json) as JObject;
        JArray jaDiscussions = (JArray)jsonObj["list"];

        //IList<string> joDiscussions = jaDiscussions.Select(c => (string)c["published"]).ToList();
        discussions = from d in jaDiscussions
                        select (new ConnectDiscussion()
                        {
                            Author = (string)d["author"]["displayName"],
                            URL = (string)d["resources"]["html"]["ref"],
                            Content = (string)d["content"]["text"],
                            Subject = (string)d["subject"],
                            Date = (DateTime)d["published"]
                        });
    }

    rptConnectFeed.DataSource = discussions.ToList();
    rptConnectFeed.DataBind();
}




Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>