开发者

Jquery with ASP.NET - My page method not returning all the records

I can't get to use the asp.net jquery thing using the page method to get what i want. I have a simple table i'm getting data from but i only get one row returned from the page method in my aspx page.Code below if anyone can help Thanks in Advance

[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")) DoSo开发者_JAVA技巧mething(data.d); else DoSomething(data); } }); function DoSomething(msg) { //$("quote_wrap").append(msg); var SComms = msg; $('quote_wrap').append //I can only get one record here alert(SComms.Title); } });

What i want as an output is e.g :

 <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>  


I agree with Cheeso and review your code :
c.ListID = rdr["ListID"].ToString();
c.ListID = rdr["Title"].ToString();

maybe must be some thing like this :
c.ListID = rdr["ListID"].ToString();
c.Title = rdr["Title"].ToString();

And if you get an error post it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜