Search code examples
c#asp.netgridviewaspxgridview

ASP.NET: Get rid of " " in Gridview


So I am currently getting a format-error (and rightfully so), because of this value. I think it is some sort of unicode space-alternative or something.

This is how I call the value:

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

This is the value while debugging: enter image description here

I need the value to be numeric OR null. Did anyone have similar problems?

UPDATE: This is how I assigned the value:

CODE BEFORE 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"  />

CODE BEHIND

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

Solution

  • try something like this

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