SqlConnection cn = null;
SqlCommand cmd = null;
SqlDataAdapter da = null;
public void OpenConnection(string SP_Name)
{
cn = new SqlConnection(ConfigurationManager.ConnectionStrings["DataListConnection"].ConnectionString);
cmd = new SqlCommand(SP_Name, cn);
cn.Open();
}
public DataTable GetDataTable(string SP_Name,Hashtable Data) {
DataTable dt = new DataTable();
OpenConnection(SP_Name);
cmd.CommandType = CommandType.StoredProcedure;
da = new SqlDataAdapter(cmd);
foreach(string Datas in Data.Keys){
cmd.Parameters.AddWithValue(Datas, Data[Datas]);
}
da.Fill(dt);
CloseConnection();
return dt;
}
public void CloseConnection() {
cn.Close();
cn.Dispose();
cmd.Dispose();
}
------------------------------------------------------------------------------------------------------------
table design
$.ajax({
type: "POST",
url: "ta.aspx/BindData",
contentType: "application/json",
data: {},
success: function (data) {
alert(data.d.length);
if (data.d.length > 0) {
var Datas = "";
Datas += "";
for (var i = 0; i < data.d.length; i++) {
if (i % 4 == 0) {
Datas += "
"; Datas += "
SqlCommand cmd = null;
SqlDataAdapter da = null;
public void OpenConnection(string SP_Name)
{
cn = new SqlConnection(ConfigurationManager.ConnectionStrings["DataListConnection"].ConnectionString);
cmd = new SqlCommand(SP_Name, cn);
cn.Open();
}
public DataTable GetDataTable(string SP_Name,Hashtable Data) {
DataTable dt = new DataTable();
OpenConnection(SP_Name);
cmd.CommandType = CommandType.StoredProcedure;
da = new SqlDataAdapter(cmd);
foreach(string Datas in Data.Keys){
cmd.Parameters.AddWithValue(Datas, Data[Datas]);
}
da.Fill(dt);
CloseConnection();
return dt;
}
public void CloseConnection() {
cn.Close();
cn.Dispose();
cmd.Dispose();
}
------------------------------------------------------------------------------------------------------------
table design
$.ajax({
type: "POST",
url: "ta.aspx/BindData",
contentType: "application/json",
data: {},
success: function (data) {
alert(data.d.length);
if (data.d.length > 0) {
var Datas = "";
Datas += "
for (var i = 0; i < data.d.length; i++) {
if (i % 4 == 0) {
Datas += "
}
Datas += "
Datas += "
" + data.d[i].NAME + " | " + data.d[i].MOBILE + " |
Datas += "
";
alert(i%4);
}
Datas += "
";
$("#data").empty();
$("#data").append(Datas);
}
},
error: function () {
}
});