How to format gridview columns?

前端 未结 2 1876
萌比男神i
萌比男神i 2021-01-26 15:42

Below is my code:

var grid = new GridView();
grid.DataSource = myDataset;

grid.DataBind();

I want to format some of the columns of my grid to

相关标签:
2条回答
  • 2021-01-26 16:34

    Google brought me here, so I thought I'd share my answer. Here's how I got to format one cell to currency in asp.net.

    With Me.ratesGridView
            .Rows(i).Cells(4).Text = FormatCurrency(.Rows(i).Cells(4).Text)
    End With
    

    Enjoy.

    0 讨论(0)
  • 2021-01-26 16:38

    Create a BoundField for the currency column with appropriate DataFormatString.

    <asp:BoundField  DataField="currencyColumnName" DataFormatString="{0:c}" />
    
    0 讨论(0)
提交回复
热议问题