I'm trying to write a bit of code that will format all the numeric values in lables in my gridview. here's what i am doing right now:
On the RowDataBound Event, i create a row object for the row that is currently being bound.
then i go use the FindControl method to grab each label by name.
Problem is there's too many columns in this table and i really dont wnat to have to type it all out. Here's an example of what i am currently doing
' Get row being bound
Dim myRow = e.Row
' Get labes to be formatted
Dim lblMunicipalIncineration = CType(myRow.FindControl("lblMunicipalIncineration"), Label)
' format labels
If lblMunicipalIncineration IsNot Nothing Then
If Not String.IsNullOrEmpty(lblMunicipalIncineration.Text) Then
lblMunicipalIncineration.Text = FormatNumber(lblMunicipalIncineration.Text, 0, TriState.False, TriState.False, TriState.True)
Can i use myRow.Controls to grab a list of all the controls and then somehow get a list of all labels in the collection and then use a for loop to go through and format each label?
View Complete Post