tags:

views:

71

answers:

1
 public string DefString { set; private get; }
    private string path = "http://someuri.org/search?Par1=15&Par2=55";
    public string GetAnswer()
    {
        WebRequest myRequest = WebRequest.Create(path);

        WebResponse myResponse = myRequest.GetResponse();

        StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.Default);
        return sr.ReadToEnd();
    }

My function GetAnswer() returns string like this:

(function(){if (typeof samo === "undefined") { samo = {}; }samo.ROOT_URL = '/search_tour?';samo.jQuery(samo.controls.resultset).html('<table class=\"res\"><thead><tr><th>DATAColum1</th><th>DATAColum2</th><th class=\"c\">DATAColum3</th><th>DATAColum4</th><th class=\"c\">DATAColum4</th></tr></thead><tbody><tr class=\"red_row\" samo:TOWNFROMINC=\"557\"><td nowrap>DATA1</td><td>DATA2</td><td class=\"c\">7</td><td>DATA3</td><td class=\"c\">DATA4</td></tr<span class=\"fr_place_l N\"></span></td></tr></tbody></table>');})();

What shall I do? I have two ways to build the table. First is to create some function that enable to convert this string to object DataTable, then I have to do something like this:

 <% foreach (System.Data.DataRow row in Model.Rows) { %>

        <%= row["column"].ToString(); %>   

 <%}%>

But It's no good way.

Second solution is to convert AnswerString into simple html table and then send it to ViewUserControl. But this way not so good as I want.

I have to use some component like DataTable , but I can not find any examples how to use it(C# MVC). Could you give me example how to use it?

For Example you have database NorthWind.mdf, DataTable control and some DropDown. If you change something in DropDown, Data table have to get new data. Please don't use DataSourses like:

    <asp:SqlDataSource ID="TourDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
        SelectCommand="SELECT [ID], [Name] FROM [TABLE]">
    </asp:SqlDataSource>

Could you give me good advice What should I do with AnswerString?

Thank for your solutions and advices=)

A: 

Take a look at .html( htmlString ) at http://api.jquery.com/html/

Vedran
Thank for answer! It was useful.I found something interesting at:http://github.com/robinvanderknaap/MvcJqGrid - It's very good example how to use jqGrid=)
Leonid