This is a migrated thread and some comments may be shown as answers.

point on header text

2 Answers 76 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Giovanni
Top achievements
Rank 1
Giovanni asked on 24 Mar 2010, 12:48 PM

Hi to all.

I use Q2 2009 version.

I have this simple table on MS SQL2005:

CREATE TABLE [dbo].[CondizioniPagamento](
 [id_CondizionePagamento] [int] IDENTITY(1,1) NOT NULL,
 [txt_Codice] [varchar](100) NOT NULL,
 [txt_Descrizione] [varchar](100) NOT NULL,
 [fl_DfFm] [bit] NOT NULL,
 [fl_AnnoCommerciale] [bit] NOT NULL,
 [n_DistanzaRata1] [int] NOT NULL,
 [n_DistanzaAltreRate] [int] NOT NULL,
 CONSTRAINT [PK_CondizionePagamento] PRIMARY KEY CLUSTERED
(
 [id_CondizionePagamento] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

with this values:
id_CondizionePagamento   xt_Codice       txt_Descrizione   fl_DfFm  fl_AnnoCommerciale   n_DistanzaRata1  n_DistanzaAltreRate
1                          Cd1           Condizione 1        True           True                60                30
2                          Cd2           Condizione 2        True           False               30                30

If I Use this view for load the RadGridView it's all ok:
SELECT     id_CondizionePagamento AS CodiceInterno, txt_Codice AS Codice, txt_Descrizione AS Descrizione, fl_DfFm AS DF,
                      fl_AnnoCommerciale AS [Anno Commerciale], n_DistanzaRata1 AS [Rata 1], n_DistanzaAltreRate AS [Altre Rate]
FROM         dbo.CondizioniPagamento

but if i change [Anno Commerciale] to [Anno Comm.] the colum if always false (not cheked)

SELECT     id_CondizionePagamento AS CodiceInterno, txt_Codice AS Codice, txt_Descrizione AS Descrizione, fl_DfFm AS DF,
                      fl_AnnoCommerciale AS [Anno Comm.], n_DistanzaRata1 AS [Rata 1], n_DistanzaAltreRate AS [Altre Rate]
FROM         dbo.CondizioniPagamento

Second problem:
If I change the name of the last field, integer,  from [Altre Rate] to [Altre Rate.] (only for example) the colum is always empty

I use this code for to load the radgrid
    Private Sub ElencoCarica()

        Dim Ds As DataSet = getDataSet()

        If Ds Is Nothing Then Return
        If Ds.Tables.Count < 1 Then Return

        RadGridView1.Enabled = True
        RadGridView1.DataSource = Ds.Tables(0)

        With RadGridView1
            For Each colonna As GridViewDataColumn In .Columns
                If colonna.FieldName.ToLower.StartsWith("codiceinterno") Then
                    colonna.IsVisible = False
                End If

                If colonna.DataType.Name = "DateTime" Then
                    colonna.FormatString = "{0:dd/MM/yyyy}"
                End If

            Next
        End With

        RadGridView1.Show()

    End Sub

    Private Function getDataSet() As DataSet
        getDataSet = New DataSet
        If _Query.Length = 0 Then Exit Function

        Try
            Dim Comando As New SqlClient.SqlCommand(_Query, _SqlConnection)
            Dim Da As New SqlClient.SqlDataAdapter(Comando)
            Da.Fill(getDataSet)

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try

    End Function

 

Regards
Giovanni

2 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 26 Mar 2010, 02:37 PM
Hi Giovanni,

When you make a DataSet from a SqlDataAdapter and a SqlCommand, the generated column names in the DataTable are the names after the AS operator in a sql query. In you case these are [Anno Comm] and [Altre Rate], but please do not use dot in these names. RadGridView supports sub properties binding and the dot symbol is parsed like a special symbol. To fix the data mapping in you scenario, just remove dot symbol from your sql query:

SELECT     id_CondizionePagamento AS CodiceInterno, txt_Codice AS Codice, txt_Descrizione AS Descrizione, fl_DfFm AS DF,                   fl_AnnoCommerciale AS [Anno Comm], n_DistanzaRata1 AS [Rata 1], n_DistanzaAltreRate AS [Altre Rate]
FROM         dbo.CondizioniPagamento

If you have additional questions, feel free to contact me.

All the best,
Julian Benkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Giovanni
Top achievements
Rank 1
answered on 26 Mar 2010, 02:54 PM

HI.
thank you for your reply.
I use dot for a short column header. I think to resolve it using the routine:

 

For i As Integer = 0 To RadGridView1.Columns.Count - 1  
            With RadGridView1.Columns.Item(i)  
                Select Case FieldName  
                    Case "Anno Commerciale" 
                       .HeaderText = "Anno comm." 
.  
.  
.  
Tags
GridView
Asked by
Giovanni
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Giovanni
Top achievements
Rank 1
Share this question
or