Linq Select if vb.net -


i have dollar amount in database column. can place data in column based on whether or not amount negative or positive, produces "0.00" in false column. how leave column blank?

the code have follows.

dim query = t in ds.hnbsavings                 order t.date descending, t.id descending                 select t.id, t.date, t.desc, debit = if(t.amount >= 0, t.amount, 0), credit = if(t.amount < 0, t.amount, 0)  dgbank.itemssource = query.tolist() 

so results 5.0000 under debits if it's positive , 0.0000 under credits functionality works, results little difficult read.

i have tried changing false declaration null, , works returns 1.0000 in false column. changed empty string " ".tostring(), runtime exception.

thanks in advance.

you returning numbers if(...) statements , there no such thing blank number. closest 0, why see result. return strings instead can show empty string.

dim query = t in ds.hnbsavings             order t.date descending, t.id descending             select t.id, t.date, t.desc, debit = if(t.amount >= 0, t.amount.tostring(), ""), credit = if(t.amount < 0, t.amount.tostring(), "")  dgbank.itemssource = query.tolist() 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -