开发者

Storing HTML in SQL and accessing it throgh Gridview

I am storing small webpages in html format in a varchar(max) column in MS 开发者_如何学CSQL server 2008. Now I want the gridview to show the column as a button/hyperlink such that when I click it, I will be redirected to a new webpage which will render the html in the table corresponding to that row.

I tried using the buttonfield control but there doesn't seem to be any way I can access the datafield and underlying html in that case. Any ideas, peeps?


Make the link to point to somepage.aspx?id=xxx, where xxx is id of the row that contains the required html. In somepage.aspx in Page_Load event read teh html from sql server and write it to the client. Something like this:

        <asp:TemplateField HeaderText="">
            <ItemTemplate>
                <a href="mypage.aspx?id=<%# Eval("ID") %>">View</a>
            </ItemTemplate>
        </asp:TemplateField>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜