[CLOSED] Repeater binding from DirectEvent

  1. #1

    [CLOSED] Repeater binding from DirectEvent

    Hi, I've ran into two issues:
    1. getting error when trying to update asp.net repeater from a directevent
    2. i can't get the hyperlinks and buttons all be on the same row (and wrap if more area is needed)
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="repeater.aspx.cs" Inherits="WEB.Test.repeater" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
    
        ICollection CreateDataSource(string source, int size)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            System.Data.DataRow dr;
            dt.Columns.Add(new System.Data.DataColumn("id", typeof(Guid)));
            dt.Columns.Add(new System.Data.DataColumn("name", typeof(String)));
            for (int i = 0; i < size; i++)
            {
                dr = dt.NewRow();
                dr[0] = Guid.NewGuid();
                dr[1] = source + i.ToString();
                dt.Rows.Add(dr);
            }
            System.Data.DataView dv = new System.Data.DataView(dt);
            return dv;
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                r1.DataSource = CreateDataSource("pageload", 5);
                r1.DataBind();
            }
        }
    
        public void click(object sender, DirectEventArgs e)
        {
            r1.DataSource = CreateDataSource("directevent", 10);
            r1.DataBind();        r1.Update();
    
        }
    </script>
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <ext:ResourceManager ID="ResourceManager1" runat="server" />
                <ext:Panel ID="Panel1" runat="server" Height="300" Title="Title">
                    <Content>
                        <asp:Repeater runat="server" ID="r1">
                            <ItemTemplate>
                                
                                <ext:HyperLink ID="h1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "name") %>' />
                                <ext:Button ID="btn" runat="server" Icon="Anchor" />
                                    
                            </ItemTemplate>
                        </asp:Repeater>
                    </Content>
                </ext:Panel>
                <ext:Button runat="server" Text="generate">
                    <DirectEvents>
                        <Click OnEvent="click" />
                    </DirectEvents>
                </ext:Button>
            </div>
        </form>
    </body>
    </html>
    Last edited by Baidaly; Feb 13, 2013 at 12:13 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Try the following:

    <%@ Page Language="C#" AutoEventWireup="true" %>
     
    <%@ Register Assembly="Ext.NET" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
     
        ICollection CreateDataSource(string source, int size)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            System.Data.DataRow dr;
            dt.Columns.Add(new System.Data.DataColumn("id", typeof(Guid)));
            dt.Columns.Add(new System.Data.DataColumn("name", typeof(String)));
            for (int i = 0; i < size; i++)
            {
                dr = dt.NewRow();
                dr[0] = Guid.NewGuid();
                dr[1] = source + i.ToString();
                dt.Rows.Add(dr);
            }
            System.Data.DataView dv = new System.Data.DataView(dt);
            return dv;
        }
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                r1.DataSource = CreateDataSource("pageload", 5);
                r1.DataBind();
            }
        }
     
        public void click(object sender, DirectEventArgs e)
        {
            r1.DataSource = CreateDataSource("directevent", 10);
            r1.DataBind(); 
            Panel1.Render(wrap, RenderMode.AddTo);
        }
    </script>
    <!DOCTYPE html>
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <ext:ResourceManager ID="ResourceManager1" runat="server" />
                <ext:Panel runat="server" ID="wrap" Border="false">
                    <Items>
                        <ext:Panel ID="Panel1" runat="server" Height="400" Title="Title">
                            <Content>
                                <asp:Repeater runat="server" ID="r1">
                                    <ItemTemplate>
                                        <ext:HyperLink ID="h1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "name") %>' />
                                        <ext:Button ID="btn" runat="server" Icon="Anchor" />
                                    </ItemTemplate>
                                </asp:Repeater>
                            </Content>
                        </ext:Panel>
                    </Items>
                </ext:Panel>
                
                <ext:Button runat="server" Text="generate">
                    <DirectEvents>
                        <Click OnEvent="click"  />
                    </DirectEvents>
                </ext:Button>
            </div>
        </form>
    </body>
    </html>
  3. #3
    Another solution (if you do not want to change your orignal markup)
    public void click(object sender, DirectEventArgs e)
        {
            X.ControlsScripting = false;
            r1.DataSource = CreateDataSource("directevent", 10);
            r1.DataBind();
            X.ControlsScripting = true;
            Panel1.UpdateContent();
     
        }
    Vladimir Shcheglov
    Sr. Developer
  4. #4
    thank you both for your solutions! Please mark as resolved

Similar Threads

  1. Replies: 1
    Last Post: Mar 27, 2012, 3:36 AM
  2. Repeater inside GridPanel
    By bruno in forum 1.x Help
    Replies: 1
    Last Post: Sep 15, 2011, 5:40 PM
  3. [1.0] Repeater and TabPanel
    By SouthDeveloper in forum 1.x Help
    Replies: 3
    Last Post: May 18, 2010, 5:28 PM
  4. Update asp.net Repeater with AjaxMethod
    By FreddieBoo in forum 1.x Help
    Replies: 3
    Last Post: Aug 13, 2009, 8:21 AM
  5. Replies: 1
    Last Post: Oct 02, 2008, 12:39 PM

Posting Permissions