2

我正在尝试创建一个链接来编辑网络网格中的每个条目,但是当我单击该链接时,它会将“ %20%20%20%20%20%20%20%20%20%20%20%20%20”附加到 url 的末尾。我不知道为什么会这样。如果我删除%20%20%20%20%20%20%20%20%20%20%20%20%20浏览器地址栏中的“”,则该链接有效。

<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>
4

2 回答 2

7

You might try trimming the parameter:

new { id = Model.OrganizationId.Trim() }
于 2013-09-09T15:07:34.267 回答
5

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.

于 2013-09-09T15:29:04.660 回答