开发者

Generating HTML from Detailsview and GridView

I've got several DetailViews and GridViews on my page, I'd like to have the HTML from the postback w/ those DetailsViews and Gridviews populated (essentially right clicking on the page and View Source). The problem is I'm not getting the data just by doing:

    WebRequest requestHTML = WebRequest.Create(baseUrl);
    WebResponse responseHTML = requestHTML.GetResponse();
    StreamReader reader = new StreamReader(responseHTML.GetResponseStream());

    String htmlContent = reader.ReadToEnd();

Instead I'm having to render each c开发者_运维问答ontrol into a StringBuilder then tack that onto my long html string. How come the first block of code just doesn't bring that data back?

    StringBuilder sb = new StringBuilder();
    StringWriter sw = new StringWriter(sb);
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    GridView1.RenderControl(hw);

So to clarify, my page displays everything correctly in the DetailsViews and GridViews, however the 1st codeset doesn't bring back the HTML containing the data from the DetailsViews and tables generated by the Gridviews.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜