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

FieldName property of GridViewDecimalColumn does not like a string with two underscores

3 Answers 33 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Johan
Top achievements
Rank 1
Johan asked on 30 Jan 2011, 12:32 PM
Hi,

I'm creating a GridViewDecimalColumn as follows:

GridViewDecimalColumn col = new GridViewDecimalColumn();
 
col.Name = node.Name;
col.FielName = node.Name;
col.HeaderText = friendlyName;

When setting the FieldName property, if node.Name = tb_Column then everything is fine. However, when node.Name = tb_Column_1 then I get a FormatException - Input string was not in a correct format.

Do I need to format that FieldName property in any special way or something?

Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 30 Jan 2011, 02:46 PM
Hi Ryno,

It should not matter what the field name is. Please can you try the following.

1: Start a new project with a RadGridView on it.
2: In form load, add the following code

this.radGridView1.AutoGenerateColumns = false;
m_myList.Add(new Person(10, "Richard"));
m_myList.Add(new Person(20, "Stew"));
m_myList.Add(new Person(30, "Chris"));
m_myList.Add(new Person(40, "Peter"));
radGridView1.DataSource = m_myList;
GridViewDecimalColumn idColumn = new GridViewDecimalColumn();
idColumn.Name = "tb_Id_1";
idColumn.HeaderText = "Id";
idColumn.FieldName = "tb_Id_1";
this.radGridView1.Columns.Add(idColumn);
GridViewTextBoxColumn nameColumn = new GridViewTextBoxColumn();
nameColumn.Name = "Name";
nameColumn.HeaderText = "Name";
nameColumn.FieldName = "Name";
this.radGridView1.Columns.Add(nameColumn);

4: Add the following class
class Person
{
    public Person()
    { }
    public Person(decimal id, string name)
    {
        this.tb_Id_1 = id;
        this.Name = name;
    }
    public decimal tb_Id_1 { get; set; }
    public string Name { get; set; }
}

Let me know if that's ok. You should just see the grid display the data without any issues.
Richard
0
Johan
Top achievements
Rank 1
answered on 07 Feb 2011, 06:01 PM
Richard, thanks again for all your help. I wrote a follow up reply solving my related issues I had with formatting etc.
0
Richard Slade
Top achievements
Rank 2
answered on 07 Feb 2011, 06:03 PM
Ah, I was just reading that. Glad you have it all sorted.
All the best
Richard
Tags
GridView
Asked by
Johan
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Johan
Top achievements
Rank 1
Share this question
or