因此,我正在获得格式错误(并且理所当然),因为这个值。我认为它是某种unicode空间替代品或其他东西。
这就是我调用这个值的方式:
int updatecount = Convert.ToInt32(row.Cells[2].Text);
我需要值为数字或null。有没有人有类似的问题?
更新:这是我分配值的方式:
<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
它将已经HTML编码的用于html传输的字符串转换为已解码的字符串。
int updatecount = Convert.ToInt32(Server.HtmlDecode(row.Cells[2].Text));
要么
int updatecount = Convert.ToInt32(row.Cells[2].Replace(" ", ""));
尝试这样的事情
int updatecount = ( IsNumeric(String.row.Cells[2].Text) ? Convert.ToInt32(String.row.Cells[2].Text) : 0 );