Encountering an issue where the code is calling a Modal, but upon loading it fails to populate the controls with values sent into the JavaScript. No errors are thrown, yet all controls remain empty. As a newcomer to AJAX and JavaScript, I suspect there might be a simple oversight on my part.
Appreciate any help!
This is the JavaScript snippet:
function RowClickedResults(sender, eventArgs) {
sender.get_masterTableView().fireCommand("View", eventArgs._itemIndexHierarchical);
}
function createEditAccount(ReceivedDate, DepositedDate, tbCompanyName, tbCheckAmount,
tbCheckNum, tbDesc, cbResultsBreak, cbResultAcctNum, tbResultBreak, tbResultNotes) {
$("#EditAccount").modal('show');
$('#EditAccount').on('load', function () {
var rDate = $telerik.findControl(document, "rdResultReceiveDate");
var dDate = $telerik.findControl(document, "rdResultDepositDate");
var Comp = $telerik.findControl(document, "tbResultCompany");
var CheckAmt = $telerik.findControl(document, "tbResultCheckAmt");
var CheckNum = $telerik.findControl(document, "tbResultCheckNum");
var Desc = $telerik.findControl(document, "tbResultsDesc");
var Break = $telerik.findControl(document, "cbResultsBreak");
var AcctNum = $telerik.findControl(document, "cbResultAcctNum");
var BreakAmt = $telerik.findControl(document, "tbResultBreak");
var Notes = $telerik.findControl(document, "tbResultNotes");
rDate.set_selectedDate = ReceivedDate;
dDate.set_selectedDate = DepositedDate;
Comp.text = tbCompanyName;
CheckAmt.text = tbCheckAmount;
CheckNum.text = tbCheckNum;
Desc.text = tbDesc;
AcctNum.value = cbResultAcctNum;
BreakAmt.text = tbResultBreak;
Notes.text = tbResultNotes;
});
}
This is the Modal structure:
<div id="EditAccount" class="modal fade" role="dialog">
...
// The rest of the Modal HTML goes here (for brevity)
...
</div>
The following section invokes my JavaScript:
<telerik:RadGrid ID="rgResults" runat="server" FooterStyle-ForeColor="#BA1A8B"
HeaderStyle-BackColor="#39ac99"
HeaderStyle-Font-Bold="true" AlternatingRowStyle-BackColor="White"
AllowPaging="true" PageSize="10"
OnItemCommand="rgResults_ItemCommand"
OnNeedDataSource="rgResults_NeedDataSource"
OnItemDataBound="rgResults_ItemDataBound"
OnPreRender="rgResults_PreRender"
AutoGenerateColumns="false">
// ClientSettings code truncated for readability
<ClientEvents OnRowClick="RowClickedResults" />
// MasterTableView code omitted for clarity
</telerik:RadGrid>
Here's how the code behind sets up the data for viewing in the Modal:
case "View":
{
foreach (GridDataItem item in rgResults.Items)
{
string Deposit = item.GetDataKeyValue("Deposited_Date").ToString();
ar = ydb.Accounts_Receivable.ToList().Where(t => t.Deposited_Date == DateTime.Parse(Deposit)).ToList();
foreach (Accounts_Receivable ar2 in ar.ToList())
{
if (SearchByDate.SelectedDate.Value.ToString() == Deposit)
{
if (ar2.Posted_Date == null)
{
Accounts_Receivable_Breakdown arb = ar2.Accounts_Receivable_Breakdown.ToList()
.Where(t => t.Accounts_Receivable_ID == ar2.Accounts_Receivable_ID).First();
ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(),
"createEditAccount(\"" + ar2.Received_Date.Value.ToString() + "\",\"" + ar2.Deposited_Date.ToString() + "\",\"" +
ar2.Company_Name + "\",\"" + ar2.Check_Amount + "\",\"" + ar2.Check_Number + "\",\"" +
ar2.Description_ + "\",\"" + arb.Breakdown_Amount +
"\",\"" + arb.Account_Number + "\",\"" + arb.Breakdown_Amount + "\",\"" + arb.Notes + "\");", true);
}
else
{
// Code for scenarios when Posted_Date exists - not shown here for conciseness
}
}
}
}
break;
}