Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
I am trying to populate A subgrid in a webgrid that is a nested webgrids. I am getting conflict in paging of the subgrids. When i select page 2 of a subgrid all the other subgrids in the webgrid changes to page 2 that is incorrect. only that subgrids should be affected for which is clicked paged 2. can anyone guide me through this ?


What I have tried:

@grid.GetHtml(htmlAttributes: new { ID = "grdSSI" }, tableStyle: "webGrid", displayHeader: true,
headerStyle: "header",
alternatingRowStyle: "alt",
selectedRowStyle: "select",

columns:
grid.Columns(
grid.Column("SSIGroupName", @HomeResource.SSIGridGroupName, format: item => Html.Raw("" + (item.SSIGroupName).ToString() + ""), style: "POAGridMarketName"),
grid.Column("SegAccountRequired", @HomeResource.SSIGridSegregateAccountRequired),
grid.Column("FXRequired", @HomeResource.SSIGridFXRequired),
grid.Column("StatusDesc", @HomeResource.GridStatus),
//grid.Column("", "", format: (item) => Html.ActionLink("Delete", "DeleteSSI", new { ssiID = item.SSIID, customerName = Model.CustomerName, accountNumber = Model.AccountNumber, asOfDate = Model.AsOfDate }, new { @class = "deleteImg DeleteSSI" })),
grid.Column("", "Delete", format: (item) =>
{
var colorStyle = "";
if (item.IsPending == true)
{
colorStyle = "yellow";
}
else
{
colorStyle = "white";
}

var disableStyle = "";
if (item.StatusCode == "IA" || item.StatusCode == "UA" || item.StatusCode == "RA" || item.StatusCode == "DR")
{
disableStyle = "showDelete";
}
else
{
disableStyle = "";
}
return Html.ActionLink("Delete", "DeleteSSI", new { ssiID = item.SSIID, groupName = Model.GroupName, customerName = Model.CustomerName, accountNumber = Model.AccountNumber, asOfDate = Model.AsOfDate }, new { @class = "deleteImg DeleteSSI " + colorStyle + " " + disableStyle, title = "Delete" });
}),
grid.Column("", "Recover", format: (item) =>
{
var disableStyle = "";
if (item.StatusCode == "DA" || item.StatusCode == "RR")
{
disableStyle = "showRecover";
}
else
{
disableStyle = "";
}

return Html.ActionLink("Recover", "RecoverSSI", new { ssiID = item.SSIID, groupName = Model.GroupName, customerName = Model.CustomerName, accountNumber = Model.AccountNumber, asOfDate = Model.AsOfDate }, new { @class = "recoverImg RecoverSSI " + disableStyle, title = "Recover" });
}),

grid.Column(format: (item) =>
{
WebGrid subGrid = new WebGrid(source: item.SSISecurityCashAccountMapping, canSort: false);
return subGrid.GetHtml(htmlAttributes: new { id = "grdSSIAccounts" + item.SSIID }, tableStyle: "webGrid", displayHeader: true,
headerStyle: "header",
columns: subGrid.Columns(
subGrid.Column("AccountNumber", @HomeResource.SSIGridAccountNumber),
subGrid.Column("DepositoryCode", @HomeResource.SSIGridDepository),
subGrid.Column("SubCustodianName", @HomeResource.SSIGridSubCustodian),
subGrid.Column("SecurityAccountNumber", @HomeResource.SSIGridSecurityAccount),
subGrid.Column("CashAccountNumber", @HomeResource.SSIGridCashAccount)));
})
))
Posted
Updated 24-Aug-16 3:19am

1 solution

Try giving the sub-grid a FieldNamePrefix[^]:
C#
WebGrid subGrid = new WebGrid(source: item.SSISecurityCashAccountMapping, canSort: false, fieldNamePrefix: item.SSIID);
 
Share this answer
 
Comments
prateikshukla 25-Aug-16 6:38am    
Hi @Richard, I implemented your solution now its throwing below error :
The best overloaded method match for 'System.Web.Helpers.WebGrid.WebGrid(System.Collections.Generic.IEnumerable<object>, System.Collections.Generic.IEnumerable<string>, string, int, bool, bool, string, string, string, string, string, string, string)' has some invalid arguments
prateikshukla 25-Aug-16 6:53am    
Hey i got the solution i just had to give it a string value thanks alott

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900