Click here to Skip to main content
15,914,010 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Need a solution for my problem Pin
indian14314-Apr-14 6:01
indian14314-Apr-14 6:01 
GeneralRe: Need a solution for my problem Pin
Nico Haegens14-Apr-14 11:56
professionalNico Haegens14-Apr-14 11:56 
Questionapply styles in excel with Openxml Pin
byka10-Apr-14 6:18
byka10-Apr-14 6:18 
QuestionConverting aspx pages into ascx pages Pin
indian1439-Apr-14 14:08
indian1439-Apr-14 14:08 
AnswerRe: Converting aspx pages into ascx pages Pin
Blikkies9-Apr-14 22:55
professionalBlikkies9-Apr-14 22:55 
GeneralRe: Converting aspx pages into ascx pages Pin
indian14310-Apr-14 6:08
indian14310-Apr-14 6:08 
GeneralRe: Converting aspx pages into ascx pages Pin
Blikkies10-Apr-14 23:25
professionalBlikkies10-Apr-14 23:25 
QuestionGridviews and hyperlinks help please Pin
Tumtum219-Apr-14 1:21
Tumtum219-Apr-14 1:21 
Hey Guys
i have to create a webpage that has a button and gridview, once the button is pressed it triggers the click button method which searches my computer for files in a specific folder once files are found it displays it in the grid view .
which i have managed to do my problem is im expected to then give the ability that if the user clicks on the file name(which is a hyperlink) in the grid view that it opens on a new page and that the file is embed in that page ready for viewing??

i have tried all i can think off.

ps the files not in a db they in a folder on my pc later will be on a sever in a folder

hope some on can help me

here is what i have so far
ASP.NET
<form id="form1" runat="server">
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="119px" >
            <Columns>
                <asp:TemplateField HeaderText="FileName">
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink1"  runat="server" NavigateUrl='<%# Eval("Dir","~/Dir={0}")%>' Text='<%# Eval("File") %>' PostBackUrl="/WebForms4.aspx">  </asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="size" HeaderText="size" />
                <asp:TemplateField HeaderText="diretory">
                    <ItemTemplate>
                        
                        <asp:Button ID="Button2" runat="server" CommandArgument='<%# Eval("Dir","~/WebForms4.aspx/files?Dir={0}") %>' Text='<%# Eval("Dir") %>' PostBackUrl="~/WebForms4.aspx?Dir={0}" />
                
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>


and C# code
C#
protected void Button1_Click(object sender, EventArgs e)
       {
           DataTable Dt = new DataTable();
           Dt.Columns.Add("File", typeof(string));
           Dt.Columns.Add("Size", typeof(string));
           Dt.Columns.Add("Dir", typeof(string));
           foreach (string filename in Directory.GetFiles(@"C:\files"))
           {
               FileInfo fileinfo = new FileInfo(filename);
               Dt.Rows.Add(fileinfo.Name, fileinfo.Length +"KB", fileinfo.FullName);


           }
           GridView1.DataSource = Dt;
           GridView1.DataBind();
       }



Thanks in advancedThumbs Up | :thumbsup:
Questioni am not able to insert images to word document created through C# Pin
sonu jnnce8-Apr-14 22:42
sonu jnnce8-Apr-14 22:42 
AnswerRe: i am not able to insert images to word document created through C# Pin
Schatak10-Apr-14 2:06
professionalSchatak10-Apr-14 2:06 
Questionhow to drag usercontrol to page Pin
Nico Haegens8-Apr-14 5:51
professionalNico Haegens8-Apr-14 5:51 
Questionweb api query - 401 error Pin
miss7868-Apr-14 4:57
miss7868-Apr-14 4:57 
AnswerRe: web api query - 401 error Pin
Bernhard Hiller8-Apr-14 22:18
Bernhard Hiller8-Apr-14 22:18 
GeneralRe: web api query - 401 error Pin
miss7868-Apr-14 23:57
miss7868-Apr-14 23:57 
GeneralRe: web api query - 401 error Pin
Bernhard Hiller9-Apr-14 2:19
Bernhard Hiller9-Apr-14 2:19 
GeneralRe: web api query - 401 error Pin
miss78614-Apr-14 6:24
miss78614-Apr-14 6:24 
QuestionHow to save secured password for individual users Pin
antony beula8-Apr-14 2:32
antony beula8-Apr-14 2:32 
AnswerRe: How to save secured password for individual users Pin
Peter Leow8-Apr-14 2:44
professionalPeter Leow8-Apr-14 2:44 
AnswerRe: How to save secured password for individual users Pin
Richard Deeming8-Apr-14 3:07
mveRichard Deeming8-Apr-14 3:07 
QuestionExporting Repeater values in to Excel Pin
indian1437-Apr-14 14:39
indian1437-Apr-14 14:39 
AnswerRe: Exporting Repeater values in to Excel Pin
Schatak8-Apr-14 2:24
professionalSchatak8-Apr-14 2:24 
GeneralRe: Exporting Repeater values in to Excel Pin
indian1438-Apr-14 7:08
indian1438-Apr-14 7:08 
GeneralRe: Exporting Repeater values in to Excel Pin
Schatak8-Apr-14 21:18
professionalSchatak8-Apr-14 21:18 
GeneralRe: Exporting Repeater values in to Excel Pin
indian1439-Apr-14 7:33
indian1439-Apr-14 7:33 
GeneralRe: Exporting Repeater values in to Excel Pin
Schatak10-Apr-14 2:08
professionalSchatak10-Apr-14 2:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.