Advertisement

11.21.2007 at 10:04AM PST, ID: 22976095
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

4.4

gridview and files using system.IO

Asked by vthunder70 in Programming for ASP.NET, Microsoft Visual Basic.Net, Visual Studio

Tags:

Hi experts,
I have an aspx page with a gridview control where people can see files that are store in an specific folder in the webserver. This gridview has the name of the file as a link so people can click on the name of the file and the file will open up in a new page.

I also have a dropdown list where the user can choose a different area(folder) to view the files from, and that's where the problem comes in. This works great if I'm only loading files from ONE folder only when i make it more dynamic I can't get the right path to the files.

in my code behind I have and If statement so that if the user chooses whatever section then the gridview displays the data from that folder... BUT in the aspx page I got this

Container.DataItem,"fileName", "~/hr/pdfs/{0} "
I need to make the hr/pdfs dynamic so that when the if statement is trigger it loads the right data and also sets the right path to the files

I made a public variable call test and I need to place it inside the fragment mention before.
And I also will like to delete the files using the 'Delete' button tha comes with the gridView... but I can't seem to do that I tryed really hard a couple of days ago and I had no luck
Thanks alot guysStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
aspx page
<p>
<asp:DropDownList ID="hardGoodsChoices" runat="server" AutoPostBack="True">
        <asp:ListItem>--PLEASE CHOOSE--</asp:ListItem>
        <asp:ListItem>General</asp:ListItem>
        <asp:ListItem>Weights and Measures</asp:ListItem>
        <asp:ListItem>Sales Programs/Pricing Info</asp:ListItem>
</asp:DropDownList>
</p>
 
<asp:GridView ID="gridview" runat="server" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" PageSize="15">
    <Columns>
        <asp:TemplateField HeaderText="File Name" SortExpression="fileName">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%#  DataBinder.Eval(Container.DataItem,"fileName") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Hyperlink ID="Hyperlink1" runat="server" Text='<%#  DataBinder.Eval(Container.DataItem,"fileName") %>' 
                        NavigateUrl='<%# DataBinder.Eval(Container.DataItem,"fileName", "~/hr/pdfs/{0} ") %>' Target="_blank"></asp:Hyperlink>
                    </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="fileDate" HeaderText="File Date" SortExpression="fileDate" />
        <asp:BoundField DataField="fileSize" HeaderText="File Size" SortExpression="fileSize" />   
        
    </Columns>
</asp:GridView>
<%=Test%>
 
==================aspx.vb page================
Imports System.IO
Imports System.Text.RegularExpressions
Partial Class files_hardGoods
    Inherits System.Web.UI.Page
    Public test As String
    'Public sFolder As String
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Master.Page.Header.Title = "Hard Goods"
 
        If Page.IsPostBack Then
            BindGrid()
        End If
    End Sub
    Private Sub BindGrid()
 
        'The line below is for my local machine use the line after is for web server use
        'Dim sFolder As String = "C:\Documents and Settings\Roderick Morales\Desktop\newIntranet\hr\pdfs"
        'the line below is for webserver machine
        Dim sFolder As String
        If hardGoodsChoices.Text = "General" Then
            sFolder = "C:\Inetpub\NewIntranet\files\filesUploaded\hard_goods\sales"
            test = "files/filesUploaded/hard_goods/sales"
        ElseIf hardGoodsChoices.Text = "Weights and Measures" Then
            sFolder = "C:\Inetpub\NewIntranet\files\filesUploaded\hard_goods\weights_measures"
            test = "files/filesUploaded/hard_goods/weights_measures"
        ElseIf hardGoodsChoices.Text = "Sales Programs/Pricing Info" Then
            sFolder = "C:\Inetpub\NewIntranet\files\filesUploaded\hard_goods\pricing"
            test = "files/filesUploaded/hard_goods/pricing"
        Else
            Response.Redirect("hardGoods.aspx")
        End If
        Dim dtFiles As New Data.DataTable
 
        'dtFiles.Columns.Add(New Data.DataColumn("fileName"))
        'dtFiles.Columns.Add(New Data.DataColumn("fileDate"))
        'dtFiles.Columns.Add(New Data.DataColumn("fileSize"))
        'the lines above just call the columns but without giving them a data type
        'the lines below gives the columns a datatype so that they can be sorted
        dtFiles.Columns.Add(New Data.DataColumn("fileName", System.Type.GetType("System.String")))
        dtFiles.Columns.Add(New Data.DataColumn("fileDate", System.Type.GetType("System.DateTime")))
        dtFiles.Columns.Add(New Data.DataColumn("fileSize", System.Type.GetType("System.Int64")))
 
        For Each file As String In System.IO.Directory.GetFiles(sFolder, "*.*")
            Dim fInfo As System.IO.FileInfo = New System.IO.FileInfo(file)
 
            Dim dr As Data.DataRow = dtFiles.NewRow
 
 
            dr("fileName") = fInfo.Name
            dr("fileDate") = fInfo.LastWriteTime
            dr("fileSize") = fInfo.Length
 
            dtFiles.Rows.Add(dr)
 
            dtFiles.AcceptChanges()
 
        Next
 
        'gridview.DataSource = dtFiles
        Dim dv As System.Data.DataView = New System.Data.DataView(dtFiles)
 
        If gridSortExpression <> "" Then
            dv.Sort = gridSortExpression + " " + IIf(gridSortDirection = SortDirection.Ascending, "DESC", "ASC")
        End If
        gridview.DataSource = dv
        gridview.DataBind()
 
        'gridview.DataBind()
 
 
    End Sub
[+][-]11.21.2007 at 03:19PM PST, ID: 20331819

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Microsoft Visual Basic.Net, Visual Studio
Tags: gridview
Sign Up Now!
Solution Provided By: MCKreed
Participating Experts: 2
Solution Grade: B
 
 
[+][-]11.24.2007 at 03:21PM PST, ID: 20344257

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 07:50AM PST, ID: 20350616

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.26.2007 at 08:30AM PST, ID: 20350959

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 09:39AM PST, ID: 20351456

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 10:21AM PST, ID: 20351762

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 05:50PM PST, ID: 20354801

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 06:13PM PST, ID: 20354878

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 04:19AM PST, ID: 20357249

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 07:20AM PST, ID: 20358469

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.28.2007 at 11:11AM PST, ID: 20367791

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.30.2007 at 11:20AM PST, ID: 20384551

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.30.2007 at 11:47AM PST, ID: 20384761

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.30.2007 at 01:40PM PST, ID: 20385519

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.30.2007 at 01:50PM PST, ID: 20385569

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.01.2007 at 08:17AM PST, ID: 20388338

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.01.2007 at 10:37AM PST, ID: 20388866

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.01.2007 at 10:47AM PST, ID: 20388896

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.01.2007 at 01:18PM PST, ID: 20389278

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.04.2007 at 12:48PM PST, ID: 20406278

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628