后台代码:
using System; 
using System.Data; 
using System.Configuration; 
using System.Collections; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
 
public partial class NET_Default : System.Web.UI.Page 
{ 
 DataTable DT = new DataTable(); 
 DataColumn DC = new DataColumn(); 
 DataRow DR; 
 protected void Page_Load(object sender, EventArgs e) 
 { 
 AjaxPro.Utility.RegisterTypeForAjax(typeof(NET_Default)); 
 if (!Page.IsPostBack) 
 { 
 CreateDataTable(); 
 
 for (int i = 0; i < 3; i++) 
 { 
 DR = DT.NewRow(); 
 DR["ID"] = i.ToString(); 
 DR["UserName"] ="胡果" + i.ToString(); 
 DR["Keyword"] = "欢迎你ws_hgo" + i.ToString(); 
 DT.Rows.Add(DR); 
 } 
 
 } 
 DataList1.DataSource = DT; 
 DataList1.DataBind(); 
 } 
 public void CreateDataTable() 
 { 
 DC = new DataColumn(); 
 DC.ColumnName = "ID"; 
 DC.DataType = System.Type.GetType("System.Int32"); 
 //DC = new DataColumn("ID", System.Type.GetType("System.Int32")); 
 DT.Columns.Add(DC); 
 DC = new DataColumn(); 
 DC.ColumnName = "UserName"; 
 DC.DataType = System.Type.GetType("System.String"); 
 DT.Columns.Add(DC); 
 DC = new DataColumn(); 
 DC.ColumnName = "Keyword"; 
 DC.DataType = System.Type.GetType("System.String"); 
 DT.Columns.Add(DC); 
 
 } 
 [AjaxPro.AjaxMethod] 
 public string ReturnTable(string Name) 
 { 
 string res; 
 //我这里有数组代替 
 string[] str = new string[] { "胡果0", "胡果1", "胡果2" }; 
 if (Array.IndexOf(str, Name) != -1) 
 { 
 res = "欢迎大家来到" + Name.Substring(0,Name.Length-1).ToString() + "http://blog.csdn.net/ws_hgo"; 
 } 
 else 
 { 
 res = "无!"; 
 } 
 return res; 
 } 
} 
赞
If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)


QQ:154298438
QQ:417480759