Mezillinu
asked on
Converting asp.net grid view formatting to datagrid formatting
I have this function that excepts a dataview, then it goes through all its columns searches if they are numeric, and if numeric divides the thousands by commas and 2 decimal places.
I want this function to accept a DATAGRID not a DATAVIEW.
Thanks, any help is greatfully appreciated.
I want this function to accept a DATAGRID not a DATAVIEW.
Thanks, any help is greatfully appreciated.
Private Sub FormatGridColumns(ByVal gv As GridView)
For j As Integer = 0 To gv.Rows.Count - 1 'loop through all rows
If gv.Rows(j).RowType = DataControlRowType.DataRow Then 'Make sure it's not the header/footer of the grid
Dim num As Decimal = 0.0 'a variable to hold the data
For i As Integer = 0 To gv.Rows(j).Cells.Count - 1 'loop through each cell in the row
If IsNumeric(gv.Rows(j).Cells(i).Text) = True Then 'see if the value is a number
num = CType(gv.Rows(j).Cells(i).Text, Decimal) 'if it is a number, assign to variable
gv.Rows(j).Cells(i).Text = FormatNumber(num, 2, True, False, True) 'format the variable and write the text back to the cell
End If
Next
End If
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
that is it .. no need of loop or function to call ..