but it's not calling even single webmethod
if there are 2 ajax method to bind 2 gridview then its not calling webmethod
DataTable dummy = new DataTable();
dummy.Columns.Add("message");
dummy.Columns.Add("date");
dummy.Columns.Add("time");
dummy.Columns.Add("direction");
dummy.Rows.Add();
grdchat.DataSource = dummy;
grdchat.DataBind();
DataTable dummy1 = new DataTable();
dummy1.Columns.Add("message");
dummy1.Columns.Add("date");
dummy1.Columns.Add("time");
dummy1.Columns.Add("direction");
dummy1.Rows.Add();
grdchat1.DataSource = dummy1;
grdchat1.DataBind();
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "clientchat();", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "consultantchat();", true);
<script type="text/javascript">
function clientchat() {
$(function () {
var m = document.getElementById("<%=txtmanagerid.ClientID%>").value;
var n = document.getElementById("<%=txtclientid.ClientID%>").value;
$.ajax({
type: "POST",
url: "chat.aspx/GetChatDatas",
data: '{managerid: "' + m + '",clientid:"' + n + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess
});
return false;
});
function OnSuccess(response) {
var chatDatas = response.d;
var row = $("[id*=grdchat] tr:last-child").clone(true);
$("[id*=grdchat] tr").not($("[id*=grdchat] tr:first-child")).remove();
for (var i = 1; i < chatDatas.length; i++) {
for (var j = 0; j < chatDatas[i].length; j++) {
$("td", row).eq(j).html(chatDatas[i][j] );
}
$("[id *= grdchat]").find("table th").eq(chatDatas[i].length - 1).hide();
$("[id*=grdchat]").append(row);
row = $("[id*=grdchat] tr:last-child").clone(true);
}
}
}
</script>
<script type="text/javascript">
function consultantchat() {
$(function () {
var r = document.getElementById("<%=txtmanagerid.ClientID%>").value;
var s = document.getElementById("<%=txtconsultantid.ClientID%>").value;
$.ajax({
type: "POST",
url: "chat.aspx/GetChatDatas1",
data: '{managerid: "' + r + '",consultantid:"' + s + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess
});
return false;
});
function OnSuccess(response1) {
var chatDatas1 = response1.d;
var row = $("[id*=grdchat1] tr:last-child").clone(true);
$("[id*=grdchat1] tr").not($("[id*=grdchat1] tr:first-child")).remove();
for (var i = 1; i < chatDatas1.length; i++) {
for (var j = 0; j < chatDatas1[i].length; j++) {$("td", row).eq(j).html(chatDatas[i][j]);
}
$("[id *= grdchat1]").find("table th").eq(chatDatas1[i].length - 1).hide();
$("[id*=grdchat1]").append(row);
row = $("[id*=grdchat1] tr:last-child").clone(true);
}
}
}
</script>
Webmethod
[WebMethod]
public static List<object> GetChatDatas(string managerid,string clientid)
{
sqlwebmethod sql = new sqlwebmethod();
DataSet ds6 = sql.getds("select chatprocess.chat_id,chatprocess.message,chatprocess.sender,direction,convert(varchar(15),date,113) as date,time from chatprocess join managers on managers.managerid=chatprocess.manager_id where chatprocess.manager_id='" + managerid + "' and client_id='" + clientid + "' order by chat_id desc ");
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] {
new DataColumn("message"),
new DataColumn("date"),
new DataColumn("time"),
new DataColumn("direction")});
if (ds6.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds6.Tables[0].Rows.Count; i++)
{
dt.Rows.Add(ds6.Tables[0].Rows[i]["message"].ToString(), ds6.Tables[0].Rows[i]["date"].ToString(),ds6.Tables[0].Rows[i]["time"].ToString(), ds6.Tables[0].Rows[i]["direction"].ToString());
}
}
DataSet ds5 = new DataSet();
ds5.Tables.Add(dt);
List<object> chatDatas = new List<object>();
object[] chatData = new object[ds5.Tables[0].Columns.Count];
for (int i = 0; i < ds5.Tables[0].Columns.Count; i++)
{
chatData[i] = ds5.Tables[0].Columns[i].ColumnName;
}
chatDatas.Add(chatData);
for (int i = 0; i < ds5.Tables[0].Rows.Count; i++)
{
chatData = new object[ds5.Tables[0].Columns.Count];
for (int j = 0; j < ds5.Tables[0].Columns.Count; j++)
{
chatData[j] = ds5.Tables[0].Rows[i][j];
}
chatDatas.Add(chatData);
}
return chatDatas;
}
[WebMethod]
public static List<object> GetChatDatas1(string managerid, string consultantid)
{
sqlwebmethod sql = new sqlwebmethod();
DataSet ds6 = sql.getds("select chatprocess.chat_id,chatprocess.message,chatprocess.sender,direction,convert(varchar(15),date,113) as date,time from chatprocess join managers on managers.managerid=chatprocess.manager_id where chatprocess.manager_id='" + managerid + "' and consultant_id='" + consultantid + "' order by chat_id desc ");
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] {
new DataColumn("message"),
new DataColumn("date"),
new DataColumn("time"),
new DataColumn("direction")});
if (ds6.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds6.Tables[0].Rows.Count; i++)
{
dt.Rows.Add(ds6.Tables[0].Rows[i]["message"].ToString(), ds6.Tables[0].Rows[i]["date"].ToString(), ds6.Tables[0].Rows[i]["time"].ToString(), ds6.Tables[0].Rows[i]["direction"].ToString());
}
}
DataSet ds5 = new DataSet();
ds5.Tables.Add(dt);
List<object> chatDatas = new List<object>();
object[] chatData = new object[ds5.Tables[0].Columns.Count];
for (int i = 0; i < ds5.Tables[0].Columns.Count; i++)
{
chatData[i] = ds5.Tables[0].Columns[i].ColumnName;
}
chatDatas.Add(chatData);
for (int i = 0; i < ds5.Tables[0].Rows.Count; i++)
{
chatData = new object[ds5.Tables[0].Columns.Count];
for (int j = 0; j < ds5.Tables[0].Columns.Count; j++)
{
chatData[j] = ds5.Tables[0].Rows[i][j];
}
chatDatas.Add(chatData);
}
return chatDatas;
}
it's not calling webmethod