Html in a gridview

你说的曾经没有我的故事 提交于 2019-12-25 07:05:42

问题


I have a gridview databound by a datatable. In one of the columns the people who enter the data put in the location of their facility and a link to their website in the same cell. Like:

Baltimore, MD <a href="www.location.com">Location</a>

How do I make it so the link is read as html?

gridview code:

<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False">
     <Columns>
        <asp:BoundField DataField="start_date" HeaderText ="Start Date" DataFormatString="{0:d}" HtmlEncode="False"  />
        <asp:BoundField DataField="end_date" HeaderText ="End Date" DataFormatString="{0:d}" HtmlEncode="False"  />
        <asp:BoundField DataField="sponsor" HeaderText ="Sponsor" />
         <asp:HyperLinkField DataNavigateUrlFields ="sponsor_id"
             DataNavigateUrlFormatString="http://www.cdc.gov/niosh/topics/spirometry/sponsors.html#c{0}"
             HeaderText ="Sponsor Details"
             Text="Details"/>
        <asp:BoundField DataField="location" HeaderText ="Location" />
        <asp:BoundField DataField="region" HeaderText="Region" />
        <asp:BoundField DataField="course_type" HeaderText ="Course Type" />
    </Columns>

They would be adding to the column bound to the location field.

SOLVED

 <Columns>
        <asp:BoundField DataField="start_date" HeaderText ="Start Date" DataFormatString="{0:d}" HtmlEncode="False" />
        <asp:BoundField DataField="end_date" HeaderText ="End Date" DataFormatString="{0:d}" HtmlEncode="False" />
        <asp:BoundField DataField="sponsor" HeaderText ="Sponsor" />
         <asp:HyperLinkField DataNavigateUrlFields ="sponsor_id"
             DataNavigateUrlFormatString="http://www.cdc.gov/niosh/topics/spirometry/sponsors.html#c{0}"
             HeaderText ="Sponsor Details"
             Text="Details"/>
        <asp:BoundField DataField="location" HeaderText ="Location" HtmlEncode="false"  />
        <asp:BoundField DataField="region" HeaderText="Region" />
        <asp:BoundField DataField="course_type" HeaderText ="Course Type" />

    </Columns>

changed htmlencode to false.

来源:https://stackoverflow.com/questions/35319985/html-in-a-gridview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!