Avatar of analogue
analogueFlag for United Kingdom of Great Britain and Northern Ireland asked on

Add filename from datasource to end of filesystem path


I am trying to display a Flash Video on a page with the FILENAME supplied to an asp.net flash video control from a sqldatasource. I have filtered my sqldatasource with a value sent by the querystring and that works ok pulling back the required data.

I have put my flash movie control inside an asp:repeater to enable me to pull in the data (this works ok because I have some text labels that pull in data just fine - see txt labels in code). I'm using a flashvideo control from http://www.aspnetflashvideo.com/

My files are stored in the filesystem (in the public part of my website /uploads/airtimetv/*******.flv)

I have a hard coded path that leads to where my flash file are stored on my server and I'd like to stick a filename from the datasource to the end of the path to achieve this...


The part I want pulled from my datasource is 'movie.flv' which will be different for each movie that is selected from a list on the previous page.

I have my aspx code set like up this

VideoURL='uploads/airtimetv/<% #Eval("moviefile")%>' & this doesn't work.

I'm assuming that there needs to be some sort of C# in the codebehind to create a string that will replace the whole VideoURL but quite how I'd put that together I don't know.

Hope I've got what I'm trying to achieve clear enough - if not just shout and I'll add more info. Cheers guys.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnetionString %>" SelectCommand="SELECT * FROM [CAirtime] WHERE ([id] = @id)">
<asp:QueryStringParameter DefaultValue="0" Name="id" QueryStringField="AirtimeID" Type="Int32" />
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<div class="VideoDisplayWrapper">
<ASPNetFlashVideo:FlashVideo ID="FlashVideo1" runat="server" Height="360px" VideoURL='uploads/airtimetv/<% #Eval("moviefile")%>' Width="480px" AllowFullScreen="False" >
<p>movielabel: <asp:Label ID="movielabelLabel" runat="server" Text='<%# Eval("movielabel") %>' /></p>
<p>moviefile: <asp:Label ID="moviefileLabel" runat="server" Text='<% #Eval ("moviefile") %>' /></p>

Open in new window

.NET ProgrammingASP.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon

Give this method a shot.

 <ASPNetFlashVideo:FlashVideo ID="FlashVideo1" runat="server" Height="360px" VideoURL='<%# "uploads/airtimetv/" & Eval("moviefile") %>' Width="480px" AllowFullScreen="False" >

I gave that one a shot & it threw an error.

I've also tried these - none of which work.

VideoURL='<%# string.Format("~/uploads/airtimetv/{0}", ((Item)Container.DataItem).moviefile) %>'

VideoURL='<%# DataBinder.Eval(Container.DataItem, "moviefile", "~/uploads/airtimetv/{0}") %>'

BUT - this hardcoded path and filename displays the movie just fine.

At times I am longing for classic asp - this was so easy the OLD way.  ha ha.

Just a thought....Are you storing the entire name AND the file extension in the DB? Or just the name?

If it's just the name you would need to append the .flv

VideoURL='<%# "uploads/airtimetv/" & Eval("moviefile") & ".flv" %>'
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck

It's the full filename complete with extension. e.g. 'movie.flv' stored in the database.

I'm at a bit of a loss with it, I can get a label within my repeater to write out the path and filename perfectly if I use this

<%# DataBinder.Eval(Container.DataItem, "moviefile", "~/uploads/airtimetv/{0}") %>

but when I use this for the VideoURL it doesn't seem to like it. I keep coming back to it every few hours with fresh ideas, but I'm running out of them now.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Another angle you might try.

In your web.config file, add a key

<add key="VideoFolderPath" value="F:\websites\VideoFileStorage\"/>

Then call it like this.

Dim VideoPath as string = ConfigurationManager.AppSettings("VideoFolderPath").ToString()

Then you have a variable that will always hold the path and just plug that in instead.

Hi -  sorry for the delay in getting back on this, I've been away on vacation for a week.

Nothing I've tried works at the moment.........BUT this is all good stuff and is a big help in getting to the end result. I have used these solutions for images no problem but the flash video control isn't playing game.

I'll post back here once it's working fully.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

Thanks for your prompts on this - whilst i don't have a resolution yet this is going to help me for sure.