I'm trying to create a link to edit each entry in a web grid but when I click on the link it append "%20%20%20%20%20%20%20%20%20%20%20%20%20" to the end of the url. I have no idea why this is happening. The link works find if I remove the "%20%20%20%20%20%20%20%20%20%20%20%20%20" in the browser address bar.

<div class="divGridHistory">
     @historyDataGrid.GetHtml("webGridStyle",
        rowStyle: "gridrow",
        alternatingRowStyle: "altgridrow",
        selectedRowStyle: "webGridSelectedRow",
        displayHeader: true,
        htmlAttributes: new { id = "dedDetailDataGrid" },
        columns: historyDataGrid.Columns(
            historyDataGrid.Column("ControlGroupId", "Control Group ID", style: "webGridGroupId"),
            historyDataGrid.Column("OrganizationId", "Organization ID", style: "webGridOrganizationId"),
            historyDataGrid.Column("AleIndicator", "ALE Indicator", style: "webGridAleIndicator"),
            historyDataGrid.Column("EffectiveDate","Effective Date", style: "webGridStartDate", format: item => @Utility.FormatShortDate(item.EffectiveDate)),
            historyDataGrid.Column("ChangeReason","Change Reason", style: "webGridChangeReason"),
            historyDataGrid.Column("Edit",format:@<text>@Html.ActionLink("Edit","EditOrganizationAle","AleCalculation",new{id = Model.OrganizationId},"")</text>)
            ))
</div>
有帮助吗?

解决方案

You might try trimming the parameter:

new { id = Model.OrganizationId.Trim() }

其他提示

I think the reason for this is the field type you specified within the database. You probably use a char type with a fixed length (so it will be filled with spaces). If you use VarChar instead, it won't append the string with spaces.

Like p.s.w.g said, you can Trim() it, but that's only a work around.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top