Binding Concatnation RRS feed

  • Question

  • User-1974089095 posted


        <div class="br-bm-gd-lt" runat="server" style='background:url('+"<%#"~/Images/Projects/"+ Eval("PostImage") %>"+")"'   >

                                    this is a div inside listveiw itemtemplate   what i need is retrive image path inside bacground-image :url()  for every item


    i need the right  server format to do it with concatination

    thanks in advance

    Thursday, September 7, 2017 12:32 AM


  • User-707554951 posted

    Hi mohamedramzy780,

    From your description, you would bind data to image from url and show the path of image.

    You could refer to the following code:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#test").click(function () {     
                    var bg = $(this).css('background-image');
                    bg = bg.replace('url(', '').replace(')', '').replace(/\"/gi, "");
    <asp:ListView ID="ListView1" DataSourceID="SqlDataSource1" runat="server">
                        <table cellpadding="2" width="640px" border="1" runat="server" id="tblProducts">
                            <tr runat="server">
                                <th runat="server">Image</th>
                                <th runat="server">name</th>
                                <th runat="server">age</th>
                            <tr runat="server" id="itemPlaceholder" />
                        <tr runat="server">
                                <div id="test" style="width: 50px; height: 50px; background-image: url('<%#"../image/"+ Eval("Image") %>')">aaa</div>
                                <asp:Label ID="FirstNameLabel" runat="Server" Text='<%#Eval("name") %>' />
                            <td valign="top">
                                <asp:Label ID="LastNameLabel" runat="Server" Text='<%#Eval("age") %>' />
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [User]"></asp:SqlDataSource>


    Best regards


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 7, 2017 9:16 AM