0

I'm creating a GridView which has a balance column. Depending on the currency, I have to set its symbol to dollars or colones (my country´s currency). I'm doing good with labels, but I cant find the way to set it on the grid, only to "Mon" and "Sal" columns. A grid can have both kind of currency (if the customer have one COLONES and one DOLARS account, but just one kind per row). I dont care if i have to change to datagridview, as long as I can set the symbol. I'd really appreciate your help.

  <asp:gridview id="gvMovMesActual" runat="server" AutogenerateColumns="false">
   <columns>
      <asp:boundfield datafield="num" headertext="Num" />
      <asp:boundfield datafield="desc" headertext="Desc"/>
      <asp:boundfield datafield="fec"  headertext="Fec" />
      <asp:boundfield datafield="mon"  headertext="Mon" DataFormatString="{0:C3}" />
      <asp:boundfield datafield="sal"  headertext="Sal" DataFormatString="{0:C3}" />
    </columns>
   </asp:gridview>


   Private Function setCulture (ByVal pcurrency as string) As System.IFormatProvider
     Dim cultura as System.IFormatProvider

     Select Case pcurrency
       Case "COLONES"
         cultura= CultureInfo.CreateSpecificCulture("es-CR")
       Case "DOLARES"
         cultura = CultureInfo.CreateSpecificCulture("en-US")
      End Select

    return cultura
   End Function


   Private Sub getMovs()
      Dim ds as DataSet = New DataSet
      ws = New WebserviceToBringData
      ds= ws.bringsOkTheData()

     if ds is not nothing then
       gvMovMesActual.dataSource = ds
       gvMovMesActual.DataBind()
     end if

    End Sub

2 Answers2

0

Following is a solution given to a similar situation like yours.

multibinding

Community
  • 1
  • 1
voddy
  • 950
  • 1
  • 11
  • 21
0

Since you have also asked for DataGridView...

Use the DefaultCellStyle.FormatProvider property of DataGridViewColumn to set specific cultures for individual columns.

DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
col.DefaultCellStyle.FormatProvider = CultureInfo.CreateSpecificCulture("en-CR");
Junaith
  • 3,298
  • 24
  • 34