Can not convert DataView XTemplate to CodeBehind

  1. #1

    Can not convert DataView XTemplate to CodeBehind

    Hi I have this code which works perfectly
                   <ext:DataView ID="DataView1" EmptyText="No Records" runat="server"
                            SingleSelect="true"
                            Cls="img-chooser-view"
                            OverItemCls="x-view-over"
                            ItemSelector="div.thumb-wrap" StoreID="Store1">
                            <Tpl ID="Tpl1" runat="server">
                                <Html>
                                    <tpl for=".">
                                        <div class="thumb-wrap">
                                            <div class="thumb">
                                                <tpl>
                                                    <span class="ListDescription">{name}</span>
                                                    <span class="Image"><img height="60" onerror="ImageError(this);" src="{id}" /></span>
                                                </tpl>
                                            </div>
                                        </div>
                                    </tpl>
                                </Html>
                            </Tpl>
                        </ext:DataView>



    I need to put it into codebehind it doesn't work propery... the data displays but the css does not work...
            Dim DataView1 As New DataView
            DataView1.ID = "DataView1"
            DataView1.Border = False
            DataView1.StoreID = "Store1"
            DataView1.OverItemCls = "x-view-over"
            DataView1.TrackOver = True
            DataView1.ItemSelector = "div.thumb-wrap"
    
            Dim html As String = ""
            html += "<tpl for="".""> "
            html += "<div class=""thumb-wrap"">"
            html += "<div class=""thumb"">"
            html += "<tpl>"
            html += "<span class=""ListDescription"">{name}</span>"
            html += "<span class=""Image""><img height=""60"" onerror=""ImageError(this);"" src=""{id}"" /></span>"
            html += "</tpl>"
            html += "</div>"
            html += "</div>"
            html += "</tpl>"
    
            Dim itemTpl As New XTemplate()
    
            itemTpl.Html = html
            DataView1.ItemTpl = itemTpl
    Last edited by blurken; Mar 31, 2014 at 6:13 AM.
  2. #2
    Hi @blurken,

    Here is how it could look in C#. Hope it helps.
    this.DataView1.Tpl = new XTemplate()
    { 
        Html = @"<tpl for=""."">
                    <div class=""thumb-wrap"">
                            <div class=""thumb"">
                                <tpl>
                                    <span class=""ListDescription"">{name}</span>
                                    <span class=""Image""><img height=""60"" onerror=""ImageError(this);"" src=""{id}"" /></span>
                                </tpl>
                            </div>
                        </div>
                </tpl>"
    };
  3. #3
    Perfect thanks

Similar Threads

  1. [CLOSED] xtemplate in codebehind with Data Loader
    By mirwais in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 21, 2013, 10:07 AM
  2. Replies: 0
    Last Post: Nov 29, 2011, 9:41 AM
  3. [CLOSED] Can't Convert XTemplate example to CodeBehind
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 05, 2010, 10:25 AM
  4. [CLOSED] [1.0]Convert markup DirectEvent to codebehind
    By betamax in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 19, 2010, 11:31 AM
  5. [CLOSED] Try to use DataView, XTemplate has no data...
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 22, 2010, 6:40 PM

Posting Permissions