简体   繁体   中英

How to display image and text in the same GridView cell?

I am a learner of asp.net and GridView . I have one string variable like this

string aboutSection = "<p><img class="fr-dib" src="http://i.froala.com/download/2bf8927c7f863ce9b3f3c726f4dccb94b0ec6ef8.PNG?1452253682" style="width: 300px;">this is a text</p>"

Which I have got from a RichTextEditor ( Froala Editor). Now I want to display the image and text in the same cell of GridView .

My GridView looks like below:

<asp:GridView ID="showDataGridView" runat="server" AutoGenerateColumns="False">
    <Columns>
        <asp:TemplateField HeaderText="Name">
            <ItemTemplate>
                <asp:Label runat="server" Text='<%#Eval("Name") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="About">
            <ItemTemplate>
                <asp:Literal runat="server" Text='<%#Container.DataItem %>'></asp:Literal>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

I am getting this instead of image and text :

在此处输入图片说明

Thanks in advance.

尝试

Text='<%# DataBinder.Eval(Container.DataItem, "About") %>'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM