Link to home
Start Free TrialLog in
Avatar of analogue
analogueFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Add filename from datasource to end of filesystem path

ASP.NET C# WEB PAGE + SQL SERVER 2005 DB

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...

VideoURL="~/uploads/airtimetv/movie.flv"

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)">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="0" Name="id" QueryStringField="AirtimeID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
 
 
 
 
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<div class="VideoDisplayWrapper">
<ASPNetFlashVideo:FlashVideo ID="FlashVideo1" runat="server" Height="360px" VideoURL='uploads/airtimetv/<% #Eval("moviefile")%>' Width="480px" AllowFullScreen="False" >
</ASPNetFlashVideo:FlashVideo>
</div>
 
<p>movielabel: <asp:Label ID="movielabelLabel" runat="server" Text='<%# Eval("movielabel") %>' /></p>
<p>moviefile: <asp:Label ID="moviefileLabel" runat="server" Text='<% #Eval ("moviefile") %>' /></p>
</ItemTemplate>
</asp:Repeater>

Open in new window

Avatar of ApexCo
ApexCo
Flag of United States of America image

Give this method a shot.

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

ASKER

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.
VideoURL="uploads/airtimetv/movie.flv"

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" %>'
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.
ASKER CERTIFIED SOLUTION
Avatar of ApexCo
ApexCo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Thanks for your prompts on this - whilst i don't have a resolution yet this is going to help me for sure.