我无法使用页面方法来使用asp.net jquery的东西来获得我想要的东西。我有一个简单的表我从中获取数据,但我只从我的aspx页面中的页面方法返回一行。如果有人可以帮助提前感谢
[WebMethod] public static SComms comms() { SComms c = new SComms(); string connect = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; string query = "select * from dbo.Comms where dateadd(dd, datediff(dd, 0, created), 0) = dateadd(dd, datediff(dd, +10, getdate()), 0) order by 2"; using (SqlConnection conn = new SqlConnection(connect)) { using (SqlCommand cmd = new SqlCommand(query, conn)) { conn.Open(); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { while (rdr.Read()) { c.ListID = rdr["ListID"].ToString(); c.ListID = rdr["Title"].ToString(); } } } } //} return c; }
$(document).ready(function(){$ .ajax({type:“POST”,contentType:“application / json; charset = utf-8”,data:“{}”,url:“page .aspx / Comms“,dataType:”json“,success:function(data){if(data.hasOwnProperty(”d“))DoSomething(data.d); else DoSomething(data);}}); function DoSomething( msg){//$(“quote_wrap”)。append(msg); var SComms = msg; $('quote_wrap')。append //我这里只能获得一条记录警报(SComms.Title);}});
我想要的输出是:
<blockquote> <p>Ut eu consectetur nisi. Praesent facilisis diam nec sapien gravida non mattis justo imperdiet. Vestibulum nisl urna, euismod sit amet congue at, bibendum non risus.</p> <cite>– Quote Author (Quote 1)</cite> </blockquote>
答案 0 :(得分:0)
我同意Cheeso并审核您的代码:
c.ListID = rdr [“ListID”]。ToString();
c.ListID = rdr [“Title”]。ToString();
也许必须是这样的事情:
c.ListID = rdr [“ListID”]。ToString();
c.Title = rdr [“Title”]。ToString();
如果你发布错误,那么