[CLOSED] How to create array object in codebehind

  1. #1

    [CLOSED] How to create array object in codebehind

    Hi
    Iam trying to create this array from your example site, in the code behind (dynamically). But I have not succeded. Can you please help me with this?
    
    
    
    private object[] TestData
    {
    get
    {
        DateTime now = DateTime.Now;
        return new object[]
        {
            new object[] {"3m Co", 71.72, 0.02, 0.03, now},
            new object[] {"Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, now}
        };
    }
    }
    Best regards
    Mikael Jürke
  2. #2

    RE: [CLOSED] How to create array object in codebehind

    Hi Mikael,

    Can you give us more details? Do you have compiler error or something else?

  3. #3

    RE: [CLOSED] How to create array object in codebehind

    Hi
    Sorry for beeing unclear, I want to add rows to the object in the pageload like
    PageLoad()
    {
        TestData = new object[] {"Test", "71.72", "0.02", "0.03", ""},
    }
    Best regards
    Mikael Jürke
  4. #4

    RE: [CLOSED] How to create array object in codebehind

    I don't understand what the problem do you have. If you use array as DataSource then you must use ArrayReader in Store. Can you explain what kind of problem?

    May be this example can help you https://examples1.ext.net/#/GridPanel/ArrayGrid/Simple/


  5. #5

    RE: [CLOSED] How to create array object in codebehind

    Yes I know. I want to use an array as datasource and it works great. BUT I want to add the objects dynamically and I dont know how to do that. As my first example the array contains 2 objects with the company names "3m Co" and "Wal-Mart Stores", But I dont know in advance how many objects I have, I want to be able to add theese objects in the page load method like this, but I dont know the syntax.


    
    
    
    protected void Page_Load(object sender, EventArgs e)
    {
        for (int i=0; i<10; i++)
        {
              TestData = new object[] {"Test"+i, "1", "1", "1", ""},
         }        
    }
    Hope you understand what I want to do

    Best regards
    Mikael Jürke
  6. #6

    RE: [CLOSED] How to create array object in codebehind

    Thanks for clarifications. An array don't have functionality to add new data (it is a static size structure). I can suggest next solution if you need to add new data to array

            object[] data = new object[]
                {
                    new object[] {"3m Co", 71.72, 0.02, 0.03, "9/1 12:00am"},              
                    new object[] {"Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, "9/1 12:00am"}
                };
    
            ArrayList list = new ArrayList(data);
    
            //add new data
            list.Add(new object[] {"Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, "9/1 12:00am"});
    
            this.Store1.DataSource = list.ToArray();
            this.Store1.DataBind();
    Hope this help

  7. #7

    RE: [CLOSED] How to create array object in codebehind

    Thank you! right on the spot! Works excellent!

    Best regards
    Mikael Jürke

Similar Threads

  1. [CLOSED] Added object to already create window
    By feanor91 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 23, 2012, 1:04 PM
  2. Create GridCommand at codebehind
    By marcelodecon in forum 1.x Help
    Replies: 1
    Last Post: Dec 08, 2010, 1:00 AM
  3. How to create a window codebehind?
    By snippher in forum 1.x Help
    Replies: 4
    Last Post: Mar 23, 2009, 8:42 PM
  4. [CLOSED] Grid/Store DataBind to Jagged Object Array
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 03, 2009, 4:49 PM
  5. How to create DesktopModule object
    By jack_jj in forum 1.x Help
    Replies: 0
    Last Post: Dec 08, 2008, 8:24 AM

Posting Permissions