Sign in to follow this  
ferr

[.net] ASP.Net AJAX, not working with DataList?

Recommended Posts

I have an asp:DataList with data in it including an asp:LinkButton that fires the DataList's item command handler which uses the WebClient.DownloadFileAsync method. I have a WebClient DownloadProgressChanged handler that I want to use to update an asp:Label asynchronously with the ProgressPercentage. I tried putting the label inside of an UpdatePanel, tried putting both the DataList and Label inside the UpdatePanel, and so forth, with no luck. The text on the page for the label does not change, even though when I debug into the DownloadProgressChanged handler the label is being updated accordingly. I know that there are a number of controls that are incompatible with UpdatePanel, I'm wondering if somewhere in this process something is suffering from a limitation. Or is it something else? I added in a button to test out if ajax was working at all, and I was able to update a label ajaxically. With that in mind I decided to switch out the LinkButton in the DataList with a regular Button, which should be compatible, and within the DataList's item command handler I tried updatng a label, but nothing happened. So I'm leaning towards the problem being with the DataList component.
    
public void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        pnlTransfer.Visible = true;
#region instr1
#endregion
        if (!System.IO.File.Exists(filename))
        {
            pnlVideoPlayer.Visible = false;
            pnlTransfer.Visible = true;
            wc.DownloadFileAsync(vUrl, filename);
        }
        else
        {
            pnlVideoPlayer.Visible = true;
            pnlTransfer.Visible = false;
        }
    }


    void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        lblTransfer.Text = "Transferring: " + e.ProgressPercentage.ToString() + "%";
    }


                <div id="video_list_div" style="position:absolute; width:300px; top:30px; height:auto">
                
                    <asp:Panel ID="pnlVideoList" runat="server"  
                        style="margin-top: 22px" Width="495px" BackColor=LightGray Visible=false>
                        
                        <asp:DataList id="DataList1" runat="server"
                            BorderColor="black"
                            CellPadding="3"
                            Font-Names="Verdana"
                            Font-Size="8pt"
                            HeaderStyle-BackColor="#aaaadd"
                            AlternatingItemStyle-BackColor="Gainsboro"            
                            OnItemCommand="DataList1_ItemCommand"
                            Width=100%
                            >
                              <HeaderTemplate>
                                Videos
                              </HeaderTemplate>
                              <ItemTemplate>
                              
                                <hr />
                                <%# DataBinder.Eval(Container.DataItem, "StringValue") %>                        
                                <asp:linkbutton ID="Linkbutton2" Text="[Play]" 
CommandName='<%# DataBinder.Eval(Container.DataItem, "ID") %>' 
style="color:Black;font:8pt tahoma" runat="server"/><br />
                                <hr />
                                
                              </ItemTemplate>
                        </asp:DataList>

                        
                    </asp:Panel>
                
                </div>

...
                <div id="transferring_div" style="position:absolute; left:700px; top:170px;">
                
                
                    <asp:Panel ID="pnlTransfer" runat="server" Visible=false>
                            <asp:Label ID="lblTransfer" runat="server" Text="11"></asp:Label>
                    </asp:Panel>   
                       
                    
                </div> 
                    
            </ContentTemplate>
        </asp:UpdatePanel>


[Edited by - ferr on November 9, 2008 2:13:22 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this