[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[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!

7.8

Display string as HTML in GridView

Asked by GY1680 in Programming for ASP.NET, C# Programming Language

Tags: ASP.NET C# string html gridview

I'm attempting to get a list of files in a directly.  I've been able to retrieve all the files and populate a datatable and assign the gridview datasource and the list is appearing as I want.  The only challenge is I'd like to provide a hyperlink in the "name" column so as to allow the user to click the link and open the file.  I've got the string in html, but it's displaying as plain text and I'm not sure how to ensure that the aspx page interprets the html so as to provide a link.  Please advise.  Coee attached.
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:
Code Behind:
 
    protected void Page_Load(object sender, EventArgs e)
    {
        DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/Visits/" + Request.QueryString["VID"] + "/"));
        FileInfo[] rgFiles = di.GetFiles("Output*.pdf");
 
        DataTable dTable = new DataTable("FileList");
        
        DataColumn dcName = new DataColumn();
        DataColumn dcCreationDate = new DataColumn();
        DataColumn dcLength = new DataColumn();
        
        dcName.ColumnName = "Name";
        dcName.DataType = Type.GetType("System.String");
 
        dcCreationDate.ColumnName = "Creation Time";
        dcCreationDate.DataType = Type.GetType("System.String");
 
        dcLength.ColumnName = "Length";
        dcLength.DataType = Type.GetType("System.String");
 
        dTable.Columns.Add(dcName);
        dTable.Columns.Add(dcCreationDate);
        dTable.Columns.Add(dcLength);
 
        foreach (FileInfo fi in rgFiles)
        {
            DataRow row = dTable.NewRow();
            string File = "<a href='" +fi.Name + "'>Output</a>";
            row["Name"] = File;
            row["Creation Time"] = fi.CreationTime;
            row["Length"] = fi.Length;
            dTable.Rows.Add(row);
        }
        gvFileList.DataSource = dTable;
        gvFileList.DataBind();
    }
 
Page GridView control:
 
    <asp:GridView ID="gvFileList" runat="server">
    <Columns>
    </Columns>
    </asp:GridView>
 
Page table output:
 
Name	Creation Time	Length
<a href='Output 10-14-2009 13.41.17.pdf'>Output</a>	10/14/2009 1:41:17 PM	219871
<a href='Output 10-15-2009 11.28.12.pdf'>Output</a>	10/15/2009 11:28:12 AM	219879
<a href='Output 10-15-2009 11.32.39.pdf'>Output</a>	10/15/2009 11:32:39 AM	219871
<a href='Output 10-15-2009 11.34.13.pdf'>Output</a>	10/15/2009 11:34:13 AM	219839
<a href='Output 10-15-2009 11.34.14.pdf'>Output</a>	10/15/2009 11:34:14 AM	225497
<a href='Output 10-15-2009 11.35.33.pdf'>Output</a>	10/15/2009 11:35:33 AM	219850
<a href='Output 10-15-2009 11.39.8.pdf'>Output</a>	10/15/2009 11:39:08 AM	219848
<a href='Output 10-15-2009 11.48.47.pdf'>Output</a>	10/15/2009 11:48:47 AM	219852
<a href='Output 10-15-2009 11.49.37.pdf'>Output</a>	10/15/2009 11:49:37 AM	219864
<a href='Output 10-15-2009 8.16.30.pdf'>Output</a>	10/15/2009 8:16:31 AM	216167
<a href='Output 10-15-2009 8.20.18.pdf'>Output</a>	10/15/2009 8:20:19 AM	219883
<a href='Output 10-15-2009 8.33.9.pdf'>Output</a>	10/15/2009 8:33:09 AM	319
<a href='Output 10-15-2009 8.45.53.pdf'>Output</a>	10/15/2009 8:45:53 AM	219829
<a href='Output 10-15-2009 8.48.18.pdf'>Output</a>	10/15/2009 8:48:18 AM	219820
<a href='Output 10-15-2009 9.13.7.pdf'>Output</a>	10/15/2009 9:13:07 AM	219854
<a href='Output 10-15-2009 9.3.56.pdf'>Output</a>	10/15/2009 9:03:56 AM	319
<a href='Output 10-15-2009 9.7.55.pdf'>Output</a>	10/15/2009 9:07:55 AM	219831
 
Related Solutions
Keywords: Display string as HTML in GridView
 
Loading Advertisement...
 
[+][-]10/19/09 07:40 AM, ID: 25605521Accepted Solution

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, C# Programming Language
Tags: ASP.NET C# string html gridview
Sign Up Now!
Solution Provided By: GY1680
Participating Experts: 1
Solution Grade: A
 
[+][-]10/15/09 07:45 PM, ID: 25586698Expert Comment

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.

 
[+][-]10/15/09 07:47 PM, ID: 25586711Expert Comment

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.

 
[+][-]10/16/09 08:07 AM, ID: 25590268Author Comment

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.

 
[+][-]10/16/09 08:14 AM, ID: 25590329Expert Comment

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.

 
[+][-]10/16/09 09:30 AM, ID: 25590961Author Comment

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...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625