Click here to Skip to main content
16,018,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.

I am fetching a Number from sql database to a grid view. And the number is showing. But I want that even in case of a negative number, only the number without sign is showing.

following is the code i am using for each row of datagrid:

DataGridView1.Columns(0).DataPropertyName = "FAAMOB"


Pls help.
I have tried to use a function for changing the sign but not able to provide it with the number.

VB
Dim DA As SqlDataAdapter = New SqlDataAdapter

DA.SelectCommand = New SqlCommand("Select FAAMOB from FAAM " , connection)


       Dim datatable As New DataTable
       DA.Fill(datatable)

       DataGridView1.AutoGenerateColumns = False
       DataGridView1.DataSource = datatable

       For Each row As DataGridViewRow In DataGridView1.Rows

               DataGridView1.Columns(0).DataPropertyName = "FAAMOB"
   Next
Posted
Updated 6-Feb-14 22:19pm
v2
Comments
G-code101 7-Feb-14 2:45am    
Can you clarify and also show the code of your complete method?
atul sharma 5126 7-Feb-14 4:22am    
I have entered the code in question. the issue:
*i have a decimal field in database which can also be negative
*i want to show it in datagridviewcolumn without negative sign (i.e. always positive)

hope i have been able to clear the query

done it:

I created a small function of removing the sign and changed the value of grid cell

Thanks for support
 
Share this answer
 
You need to apply loop on dataset instead of DataGridView and add condition with in the loop.


Ankur
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900