how to populate grid view with list of files. [modified]
-
hi i want to populate gridview with list of files within a directory which is a part of my project. and when user clicks on any file name then that file should open. I am using ASP.net with C#. i have pupulated the grid view with list of files but when i click on the file name it gives an error. Can anybody help me out of this. thanks in advance.
modified on Friday, February 20, 2009 5:23 AM
-
hi i want to populate gridview with list of files within a directory which is a part of my project. and when user clicks on any file name then that file should open. I am using ASP.net with C#. i have pupulated the grid view with list of files but when i click on the file name it gives an error. Can anybody help me out of this. thanks in advance.
modified on Friday, February 20, 2009 5:23 AM
Make the gridview field that the file name appears as a template field and try to get the path first.If u r storing all the files in one palce or folder means it is easy to get the path.First get the cell value and then append the path,here i am giving one eg it may help u(U have only the reference of the file in the dataGrid) here i am getting the cell value from the grid and appending with the path and then giving to play in a player aspx page ]]> Untitled Page window.moveTo(0, 0); window.resizeTo(screen.width, screen.height) function PlayIt(a) { var what='C:\\rakesh\\Music\\AnanthaBhadram\\Music\\'+a; document.getElementById('music').innerHTML='<object width="300px" height="60px" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">' +'<param name="url" value="'+what+'" />' +'<param name="uiMode" value="full" />' +'<param name="autoStart" value="true" />' +'<param name="loop" value="true" />' +'<embed type="application/x-mplayer2" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" showcontrols="true" uimode="full" width="300px" height="60px" src="'+what+'" autostart="true" loop="true">'+'</embed></object>'; return false; } function right(e) { if (navigator.appName == 'Netscape' &&(e.which == 3 || e.which == 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) { alert("Sorry, you do not have permission to right click."); return false; } return true; } document.onmousedown=right; document.onmouseup=right; if (document.layers) window.captureEvents(Event.MOUSEDOWN); if (document.layers) window.captureEvents(Event.MOUSEUP); window.onmousedown=right; window.onmouseup=right; function abc(a) { var what="C:\\rakesh\\Music\\AnanthaBhadram\\"+a; alert(what); }
-
hi i want to populate gridview with list of files within a directory which is a part of my project. and when user clicks on any file name then that file should open. I am using ASP.net with C#. i have pupulated the grid view with list of files but when i click on the file name it gives an error. Can anybody help me out of this. thanks in advance.
modified on Friday, February 20, 2009 5:23 AM
Hi... First I would like to know whether you need to get the files from the directory in the local system only or you would like to upload the files as well. If you want to get the files from the directory we can use Directory.GetFiles() method. GO through the following code. GridView1.DataSource = Directory.GetFiles("c:\\Tempu\\Upload", "*.doc"); GridView1.DataBind(); Please let me know if it serves your question. Regards Raj.