Click here to Skip to main content
15,309,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created on controller like this
public ActionResult DeleteRecordFunction(int charityID)
{
try
{
//Call your delete function to delete record
objEntities.Delete(charityID);
ViewData["deletetatus"] = "1";
}
catch
{
ViewData["deletetatus"] = "0";
}
return RedirectToAction("/CharityList/");
}



and my view is
XML
<div align="left" class="griddivshadow">
                                         @grid.GetHtml(
                                     tableStyle: "webgrid",
                                     alternatingRowStyle: "alternative-row",
                      rowStyle: "gridrow",
                               headerStyle: "",
                               footerStyle: "foot-grid",
                 mode: WebGridPagerModes.All,
                 firstText: "<< First",
                 previousText: "< Previous", nextText: "Next >",
                 lastText: "Last >>",
                 columns: new[] {
                 grid.Column("PCharityNumber","" ,canSort: true,style: "id"),
                 grid.Column("PCharityName","",canSort: true,style: "name"),
                 grid.Column("PState","",canSort: true,style: "state"),

                 grid.Column("",
                 header: "___Edit",
                 style:"grid-header",
                 format: @<text>&nbsp <a href="@Url.Action("AddCharity", "CharityView", new { charityID = Model.PCharityId })" >
                     <img width="15px" alt="" height="15px" src="../../Content/Images/Editfor.jpg" /><span
                         style="font-family: Verdana; font-size: small;">Edit</span></a>
                                         </text>
                      ),
                       grid.Column("",
                 header: "___Delete",
                 style:"grid-header",
                 format: @<text> &nbsp <a href="@Url.Action("CharityList", "PledgeNet", new { charityID = Model.PCharityId })" >
                     <img id="a" width="15px" alt="" height="15px" src="../../Content/Images/cross.png" /><span
                         style="font-family: Verdana; font-size: small;">Delete</span></a>
                                         </text>
                      )
                  })
                                     </div>






but my webgrid edit or delete ids are not passed to controller

so please resolve this
Posted
Updated 6-Feb-13 3:46am
v2
Comments
Jameel VM 6-Feb-13 13:08pm
   
where is your delete and edit column in webGrid?

1 solution

Add one more column Delete like below
C#
@grid.GetHtml(columns: new [] {
    ... // Rest of grid columns
grid.Column(
     "",
      header: "Delete",
      format: @<text>
              @Html.ActionLink("Delete", "DeleteRecordFunction", new { charityID=item.charityID} )
             </text>
  )


Hope this helps
   

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