ASP.NET: 去掉 Gridview 中的 " "

ASP.NET: Get rid of " " in Gridview

因此,由于这个值,我目前遇到格式错误(这是理所当然的)。我认为这是某种 unicode space-alternative 之类的。

我是这样称呼值的:

int updatecount = Convert.ToInt32(row.Cells[2].Text);

这是调试时的值:

我需要该值为数字或空值。有没有人有类似的问题?

更新: 这就是我分配值的方式:

之前的代码

<asp:BoundField ReadOnly="true" DataField="BASKET_ID" DataFormatString="" />
<asp:TemplateField HeaderText="Vertrags-Beginn">
    <ItemTemplate>
        <asp:TextBox runat="server" ID="STARTINGDATE"  Text='<%# ((DateTime)(Eval("CONTRACT_POS_START"))).ToShortDateString() %>'>
        </asp:TextBox><ajaxToolkit:CalendarExtender runat="server" Format="dd.MM.yyyy" ID="startingdatecalendar" TargetControlID="STARTINGDATE" />
    </ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Anzahl Tage" DataField="DAYCOUNT"  />

代码隐藏

Basket_Grid.DataSource = cdbe.VwBaskets.ToList();
Basket_Grid.DataBind();

试试 HtmlDecode

It will convert string that has been HTML-encoded for html transmission into decoded string.

int updatecount = Convert.ToInt32(Server.HtmlDecode(row.Cells[2].Text));

或者

 int updatecount = Convert.ToInt32(row.Cells[2].Replace("&nbsp;", ""));

尝试这样的事情

int updatecount = ( IsNumeric(String.row.Cells[2].Text) ? Convert.ToInt32(String.row.Cells[2].Text) : 0 );