views:

27

answers:

1

I'm building a tiny blog app, and what I need to do is show blog post title for dynamically generated content page Item.aspx in page title.

In other words, i need data that is bound to this label in FormView to also be shown in page title when page loads.

<asp:Label ID="lblPostTitle" runat="server" Text='<%# Eval("PostTitle") %>' />

I'm using ObjectDataSource to get the data.

Tried a bunch of things, tried this (http://goo.gl/zWz1) to access Eval in code behind, but nothing worked.

Edit:

OK, i got the value from returned DataTable, it's easy

protected void odsItem_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
    DataTable dt = (DataTable)e.ReturnValue;
    string postTitle = dt.Rows[0]["PostTitle"].ToString();
}

But when I pass it to Page.Title nothing happens.

Please help.

Thank you.

+1  A: 

Ok, i found the problem. Earlier, I added this code to Master page code-behind.

protected override void Render(HtmlTextWriter writer)
{
    Page.Title = "Site name" + Page.Title;
    base.Render(writer);
}

Once I commented it out, i was able to pass dynamic page title value to Page.Title.

This code worked great for appending the page title when content page Title was read from aspx file, but now i have to find another way to append the title.

Dragan