2011-01-31 73 views
0

我無法使用頁面方法使用asp.net jquery的東西來得到我想要的。我有一個簡單的表我是來自中獲取數據,但我只得到一列從下我的aspx page.Code頁面方法返回如果有人能幫助在此先感謝JQuery與ASP.NET - 我的頁面方法不返回所有記錄

[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; } 

$(文件)。就緒(函數(){$ .ajax({type:「POST」,contentType:「application/json; charset = utf-8」,data:「{}」,url:「page.aspx/Comms」,dataType:「json (data.Data); else DoSomething(data);}});函數DoSomething(msg){// $(「quote_wrap」); ).append(msg); var SComms = msg; $('quote_wrap')。append //我只能在這裏得到一條記錄alert(SComms.Title);}});

我想要什麼作爲輸出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> 
+0

修復您的格式? – Cheeso 2011-01-31 11:34:00

回答

0

我同意Cheeso並檢查你的代碼:
c.ListID = RDR [ 「ListID」]的ToString();
c.ListID = rdr [「Title」]。ToString();

也許一定是這樣的:
c.ListID = rdr [「ListID」]。ToString();
c.Title = rdr [「Title」]。ToString();

如果你有錯誤發佈它。