c# - MVC How to create dynamic DataTable? -


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 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 do? have 2 ways build table. first create function enable convert string object datatable, have this:

 <% foreach (system.data.datarow row in model.rows) { %>          <%= row["column"].tostring(); %>      <%}%> 

but it's no way.

second solution convert answerstring simple html table , send viewusercontrol. way not want.

i have use component datatable , can not find examples how use it(c# mvc). give me example how use it?

for example have database northwind.mdf, datatable control , dropdown. if change in dropdown, data table have new data. please don't use datasourses like:

    <asp:sqldatasource id="tourdatasource" runat="server"          connectionstring="<%$ connectionstrings:applicationservices %>"          selectcommand="select [id], [name] [table]">     </asp:sqldatasource> 

could give me advice should answerstring?

thank solutions , advices=)

take @ .html( htmlstring ) @ http://api.jquery.com/html/


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -