hello !
i am working on a single page of asp ,and i am using ext js 4.0 with it . i have a grid of extjs , my task is to show records in that grid from mssql server 2008 , for getting records i am using webservice . code for webservice is this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Services;
using System.IO;
using System.Text;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
using System.Runtime.Serialization;
namespace JSWorking
{
/// <summary>
/// Summary description for WebService2
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService2 : System.Web.Services.WebService
{
HttpContext postedContext = HttpContext.Current;
[WebMethod (EnableSession = true )]
[ScriptMethod (ResponseFormat = ResponseFormat .Json ,UseHttpGet = true ,XmlSerializeString = false )]
public List <Object[]> GetData ( string Name , int PhoneNo , int CellNo , int IDNo , string Advance )
{
string strCN = "Data Source=waqas\\sqlexpress2;Initial Catalog=myDB;User Id=waqas;Password=patanahi;";
SqlConnection CN = new SqlConnection(strCN);
CN.Open();
string strQuery = "Select Name,PhonenO,CellNo,IDNo,Advance from Students";
SqlCommand cmd = new SqlCommand(strQuery,CN);
cmd.CommandType = CommandType.Text;
SqlDataReader reader = cmd.ExecuteReader();
List<Object[]> myArray = new List<object[]>();
try
{
while (reader.Read())
{
Object[] values = new Object[reader.FieldCount];
int fieldCount = reader.GetValues(values);
myArray.Add(values);
}
return myArray;
}
catch (Exception ex)
{
throw ex;
}
finally
{
reader.Close ();
reader.Dispose ();
cmd.Dispose ();
CN.Close ();
CN.Dispose ();
}
}
}
}
this code is working fine , but the prob is that how can i show all the records in grid , i have no idea about JS and JSON , please help me , how to make data store , and how to get all the data from the webservice .
Please help me in this , any help will be greatly appreciated.
Best Regards