Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 642017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:07:33+00:00 2026-05-13T21:07:33+00:00

I have a SQLDataSource that is bound to a ListView control but I want

  • 0

I have a SQLDataSource that is bound to a ListView control but I want to place parts of the bound record into the HTML TITLE attribute. Here is my codebehind file that I want to change so it can use Eval to construct a dynamic TITLE based on the data content:

Public Partial Class zShowAd
Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Page.Title = " Dynamically set in ASPX page" 
        'how to use Eval here instead of the above constant ??    
    End Sub
End Class

Here is the corresponding .aspx file:

<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/zSEO.master" 
  CodeBehind="zShowAd.aspx.vb" Inherits="Zipeee.zShowAd" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
  <asp:ListView ID="ShowAd" runat="server" DataSourceID="aPosting">
    <LayoutTemplate>
      <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
    </LayoutTemplate>
   <ItemTemplate>
   <div>
    <div id="wrapper"> 
        <div id="header"></div> 
        <div id="main"> 
            <div id="nav">    AdID: <%#Eval("AdID")%></div> 
            <div id="extras">Price: <%#Eval("Price")%></div> 
            <div id="content">      <%#Eval("AdDesc")%></div> 
        </div> 
        <div id="footer"></div> 
    </div>
   </div>
  </ItemTemplate>
 </asp:ListView>

 <asp:sqldatasource runat="server" id="aPosting"
        ConnectionString="<%$ ConnectionStrings:ZIPeeeConnectionString2 %>" 
        SelectCommand="spGetAdByID" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:QueryStringParameter Name="AdId" QueryStringField="a" Type="String" />
        </SelectParameters>
    </asp:sqldatasource>
</div>
</asp:Content>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:07:34+00:00Added an answer on May 13, 2026 at 9:07 pm

    You can call a method (Sub) of the page’s code behind by putting the following somewhere inside the ItemTemplate of your ListView:

    <%# SetPageTitle(Eval("SomeProperty")) %> 
    

    Then in your code behind (sorry it’s in C#):

    protected void SetPageTitle(object title)
    {
      this.Title = title.ToString();
    }
    

    Alternatively, you can also pass the complete data item, instead of just one property:

    <%# SetPageTitle(Container.DataItem) %> 
    

    Update (to answer your comment):

    <%# ... %> is a so-called data-binding expression. It only works inside of a data-bound control (the ListView in your example) and it always works with the current record (typically you display more than one record in a data-bound control like the ListView).

    So when you use <%# Eval("Price") %>, you are displaying the value of the current record’s “Price” column. If your query, would return more than one record, then this would be executed for each record, and when setting the page title (as shown above), the page’s title would be the value from the last record.

    On the other hand <%= ... %>, is just a normal server-side code snippet (don’t know if there is a specific name for it), which does not know about the data-binding context (e.g. which is the current record).

    Please see the following question for more details: When should I use # and = in ASP.NET controls?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview that is bound to a sqldatasource. I know how to
I have a DataList that is bound to a SQlDataSource. The SQLDataSource returns a
I have an sqldatasource that takes a stored procedure with a parameter..But that the
I have a gridview that has databound items. it is bound to a SQLDATASOURCE.
I have a DataList control which is bound by SQLDataSource. The data source is
I have a gridview that is bound to a sqldatasource. The Gridview only has
I have in my Web a GridView that use SqlDatasource to insert data into
I have a gridview and sqldatasource. I want to remove the header text underline
I have a gridview and sqldatasource. I want to display in a label, the
I have a master page that divides the main content into two areas. There

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.