%20%20 ...正被添加到actionlink的末尾

Ant*_*yrd 2 .net c# actionlink asp.net-mvc-3

我正在尝试创建一个链接来编辑网格中的每个条目,但是当我点击链接时,它会将" %20%20%20%20%20%20%20%20%20%20%20%20%20" 附加到网址的末尾.我不知道为什么会这样.如果我删除%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>
Run Code Online (Sandbox Code Playgroud)

p.s*_*w.g 7

您可以尝试修剪参数:

new { id = Model.OrganizationId.Trim() }
Run Code Online (Sandbox Code Playgroud)


Jer*_*gen 5

我认为这是因为您在数据库中指定的字段类型.您可能使用具有固定长度的char类型(因此它将填充空格).如果改为使用VarChar,则不会在空格后附加字符串.

就像pswg所说,你可以修剪()它,但这只是一个解决方法.