in view:
<tbody>
@foreach (var item in Model.CallListModel)
{
<tr>
<td>
<button onclick="FillCallDetails(@item.CallNumber)" type="button" style="border: none;background-color: white;" data-target="#myModal">
@item.CallNumber
</button>
</td>
@*<td onclick="FillCallDetails(@item.CallNumber)" class="mb-control" data-box="#message-box-warning" style="cursor:pointer">@item.CallNumber</td>*@
<td>@Html.Raw(item.CallLogTime)</td>
<td>@Html.Raw(item.EnggAssignTime)</td>
<td>@Html.Raw(item.FieldActivities)</td>
<td>@Html.Raw(item.Progress)</td>
</tr>
}
</tbody>
function FillCallDetails(CallNumber) {
debugger;
$("#DivCallDetails").html("Please wait...");
$.ajax({
type: 'POST',
url: '../Master/CallDetails/',
data: { CallNumber: CallNumber },
success: function (Response) {
$("#myModal").show();
$("#DivCallDetails").html(Response);
},
error: function () {
alert("Failed");
}
});
}
in controller:
public string CallDetails(string CallNumber)
{
StringBuilder sb = new StringBuilder();
if (!string.IsNullOrEmpty(CallNumber))
{
SqlParameter[] Param = new SqlParameter[] { new SqlParameter("@CallNumber", SqlDbType.VarChar, 100) };
Param[0].Value = CallNumber;
string query = " sp_CallDetails_HpGsem";
DataTable dt = DataLayer.MasterDashBoardDB.GetDataTable(ConfigurationManager.ConnectionStrings["Hp_server"].ConnectionString, CommandType.StoredProcedure, query, Param);
if (dt.Rows.Count > 0)
{
sb.Append("<div class='mb-content'>");
sb.Append("<p>");
if (dt.Rows[0]["SubCaseID"] != DBNull.Value)
{
sb.Append("Call Number : " + dt.Rows[0]["SubCaseID"] + " <br />");
}
if (dt.Rows[0]["BranchName"] != DBNull.Value)
{
sb.Append("Branch : " + dt.Rows[0]["BranchName"] + " <br />");
}
if (dt.Rows[0]["CustomerName"] != DBNull.Value)
{
sb.Append("Customer Name : " + dt.Rows[0]["CustomerName"] + " <br />");
}
if (dt.Rows[0]["CompanyName"] != DBNull.Value)
{
sb.Append("Customer Name : " + dt.Rows[0]["CompanyName"] + " <br />");
}
["UserPhone"] + " <br />");
if (dt.Rows[0]["Address"] != DBNull.Value)
{
string Address = "Address : " + dt.Rows[0]["Address"] + "";
if (dt.Rows[0]["CityName"] != DBNull.Value)
{
Address += ", " + dt.Rows[0]["CityName"] + "";
}
if (dt.Rows[0]["Pin"] != DBNull.Value)
{
Address += ", " + dt.Rows[0]["Pin"] + " <br /> ";
}
sb.Append(Address);
}
if (dt.Rows[0]["Problem"] != DBNull.Value)
{
sb.Append("Problem : " + dt.Rows[0]["Problem"] + " ");
}
sb.Append("</p>");
sb.Append("</div>");
}
}
return sb.ToString();
}
What I have tried:
actually when i click on CallNumber it will call method using jquery ajax..
it work but the problem is it is passing the round up value of CallNumber to controller method. like my id is 412232311-961. so it pass callnumber id to method like 4122334 like this. round up value