pages

Saturday 23 March 2013

Working with Videos in Grid View Control

One of my friend asked me how do you manage videos in your Asp.Net page. In first shot i said "HTML5". After that one asked me how to display video in GridView Control.
Believe me firstly i was confused about it then i thought about what can we do inside item template to display the videos in our grid. Then first answer came to my mind (HTML5) and i was like "Oh man!!".

This post have no complicated code in it to understand. One simple grid view and Simple HTML5 video tag.
Lets start doing it:

  • Place a asp.net gridview control on your page.
  • Add all the fields from database (Here i am assuming that you are saving link to videos in your database).
  • Use what ever field you want to use for your data (Bound field/Checkbox field etc) but for video column you have to take the ItemTemplate only.



























  • Bind data to your grid. and its done.



P.S. : 

  1. Please Note that HTML5 tags don't work in every browser.
  2. In my case I m using Chrome25.
  3. Its not working in Firefox 13.
  4. For saving video url's in database dont save them using (~/Videos...)
  5. Save directly as (Videos/video.mp4)
  6. Also its not necessary that every file format will run. I tried with wmv, it didnt worked.



No comments:

Post a Comment