0

I am storing small webpages in html format in a varchar(max) column in MS SQL 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?

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

6 Comments

But then, how do I get the id to which I have to bind? I have an ID column in sql, but I don't want to show it on the gridview. Is there a way I can use that Id column without binding it to sql?
You do not have to show it in the grid, you just have to generate the link using this column
using eval()? or is there another way to do this?
yea.. this could work, i'll try it. Doesn't eval() slow down the page though?
it works, thanks :) though I have a feeling it is a dirty way of doing it. Let me know if you come across some other way too.. cheers
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.