All'interno di un controllo datalist, visualizzo il risultato di una query e, tra i vari campi, ce n'è uno che contiene una data: come posso fare per formattarla, visto che mi occorre visualizzarla solo parzialmente? Grazie...![]()
All'interno di un controllo datalist, visualizzo il risultato di una query e, tra i vari campi, ce n'è uno che contiene una data: come posso fare per formattarla, visto che mi occorre visualizzarla solo parzialmente? Grazie...![]()
...I took a heavenly ride through our silence I knew the moment had arrived
For killing the past and coming back to life...
ThePinkBox
Non ho mai usato il datalist ma con la GridView in genere mi comporto in questo modo :
e poi nel code behind implemento la funzione FormattaData()codice:<ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# FormattaData(DataBinder.Eval(Container.DataItem,"DataCreazione")) %>'></asp:Label> </ItemTemplate>
codice:/// <summary> /// FormattaData /// </summary> /// <param name="ValoreData"></param> /// <returns></returns> public string FormattaData(object ValoreData) { DateTime DateRet; if (DateTime.TryParse(ValoreData.ToString(), out DateRet)) { return DateRet.ToString("dd-MM-yyyy"); } else { return ""; } }
...NO ONE IS INNOCENT ANYMORE...
Ok, appena rientro stasera provo e ti faccio sapere...![]()
...I took a heavenly ride through our silence I knew the moment had arrived
For killing the past and coming back to life...
ThePinkBox
Funziona... Ecco le mie modifiche...
...questo nel DataList, mentre la funzione è questa...codice:<asp:Label ID="provaLabel" runat="server" Text='<%# FormattaData(Eval("campodata")) %>' />
Grazie mille.....codice:Function FormattaData(ByVal DD) As String Dim Data As String Data = Day(CDate(DD)) & " " Select Case Month(CDate(DD)) Case 1 Data = Data & "Gen." Case 2 Data = Data & "Feb." Case 3 Data = Data & "Mar." Case 4 Data = Data & "Apr." Case 5 Data = Data & "Mag." Case 6 Data = Data & "Giu." Case 7 Data = Data & "Lug." Case 8 Data = Data & "Ago." Case 9 Data = Data & "Set." Case 10 Data = Data & "Ott." Case 11 Data = Data & "Nov." Case 12 Data = Data & "Dic." End Select Data = Data & " " & Year(CDate(DD)) Return Data End Function![]()
...I took a heavenly ride through our silence I knew the moment had arrived
For killing the past and coming back to life...
ThePinkBox