Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / How to add rows with BindingList<T> data source.

How to add rows with BindingList<T> data source.

New Discussion
Todd
Todd asked on Jan 6, 2009 2:32 PM

For some reason I cannot add rows when I use a BindingList<T> data source.  I get a “Row insertion not supported by this data source.” error.  If I switch to a UltraDataSource I can add, but I would much prefer to use the bindinglist.

Is there something I can do to make it work with a binding list?

Sign In to post a reply

Replies

  • 0
    Mike Saltzman
    Mike Saltzman answered on Jan 5, 2009 4:12 PM

    BindingList<T> should certainly support adding rows. Are you trying to add the row to the grid or to the BindingList directly? 

    Are you sure you are using BindingList<T> and not IBindingList or List<T>?

    • 0
      Todd
      Todd answered on Jan 5, 2009 8:48 PM

      I couldn't use IBindingList since its abstract (an interface really).   I used BindingList<String>.

       When I clicked in the "add template row" (If that is what it is called.  The row at the bottom where you can type to insert a new reow) and got the message.

      • 0
        Mike Saltzman
        Mike Saltzman answered on Jan 6, 2009 2:28 PM

        Hm. I tried this out and I get the same results. This message doesn't come from the grid, it comes from the DotNet BindingManager. For some reason, BindingList doesn't support adding new items to the list.

        I think this might be because you are using strings. I tried a simple test like so: 

        BindingList<string> strings = new BindingList<string>();
        IBindingList bl = (IBindingList)strings;
        bl.AddNew();

        With this code, I get an error that there is no Constrcutor on type 'System.String'. So it looks like the generic BindingList can't create a new string. So you will probably need to create a class with a string property and use that rather than a list of actual strings.

      • 0
        Mike Saltzman
        Mike Saltzman answered on Jan 6, 2009 2:32 PM

        I found another way around this. Since the default IBindingList implementation of BindingList can't create a new string, you could derive a class from BindingList<string> and override AddNewCore and return a new string yourself.

        public class MyStrings : BindingList<string>
            {
                protected override object AddNewCore()
                {
                    string s = string.Empty;
                    return s;           
                }
            }

        There are probably other methods that you would need to override, also. So using a class with a string property might be easier.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Todd
Favorites
0
Replies
4
Created On
Jan 06, 2009
Last Post
17 years, 8 months ago

Suggested Discussions

Created by

Created on

Jan 6, 2009 2:32 PM

Last activity on

Feb 20, 2026 11:20 AM