C# ondalık sayı problemı

C# (C Sharp) veya Java ile ilgili konuları buraya yazabilirsiniz.
Cevapla
Kullanıcı avatarı
metemete
Üye
Mesajlar: 422
Kayıt: 21 Mar 2004 12:30
Konum: samsun
İletişim:

C# ondalık sayı problemı

Mesaj gönderen metemete »

DataGrid kullanırken bu satırda sorun yoktu : bi.Price =Int32.Parse(e.Item.Cells[3].Text);

şimdi
Datalist kullandıgım ıcın bu şekilde degiştirdim
bi.Price =Int32.Parse((e.Item.FindControl("LblFiyat") as Label).Text);

tam sayılarda sorun yok ama ondalık sayılarda hata veriyor

Kod: Tümünü seç

Input string was not in a correct format. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error: 


Line 83:                                     bi.StkKod = (e.Item.FindControl("LblKod") as Label).Text;
Line 84:                                     bi.Title = (e.Item.FindControl("LnkUrunadi") as LinkButton).Text;
Line 85:                                     bi.Price =Int32.Parse((e.Item.FindControl("LblFiyat") as Label).Text);
Line 86:                                     bi.StkBrm = (e.Item.FindControl("LblBrm") as Label).Text;
Line 87: 
 

Source File: c:\Inetpub\wwwroot\B2B\productList2.ascx.cs    Line: 85 

Stack Trace: 


[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2755599

 
Kullanıcı avatarı
lazio
Moderator
Mesajlar: 1527
Kayıt: 11 Tem 2003 04:55
Konum: İstanbul

Re: C# ondalık sayı problemı

Mesaj gönderen lazio »

null yada ondalık basamak ayıracından dolayı int e cast edemiyor olabilir.
int.parse() yerine int.TyrParse() kullanabilirsin..
DeveloperToolKit

..::|YeşilMavi|::..
Cevapla