ASP.NET:在Gridview中摆脱“”

问题描述 投票:0回答:2

因此,我正在获得格式错误(并且理所当然),因为这个值。我认为它是某种unicode空间替代品或其他东西。

这就是我调用这个值的方式:

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

这是调试时的值:enter image description here

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

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

enter image description here之前的代码

<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();
c# asp.net gridview aspxgridview
2个回答
0
投票

试试HtmlDecode

它将已经HTML编码的用于html传输的字符串转换为已解码的字符串。

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

要么

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

0
投票

尝试这样的事情

int updatecount = ( IsNumeric(String.row.Cells[2].Text) ? Convert.ToInt32(String.row.Cells[2].Text) : 0 );
© www.soinside.com 2019 - 2024. All rights reserved.