Add items to Grid on Load

4 posts, 0 answers
  1. Brett
    Brett avatar
    40 posts
    Member since:
    Mar 2008

    Posted 22 May 2008 Link to this post

    How do you add items on load with the RadGrid?

    There will always be the same few items added on data entry every time, but of course they could change sometimes, so I would like to add them to the grid, and then put the grid in edit mode.



  2. Brett
    Brett avatar
    40 posts
    Member since:
    Mar 2008

    Posted 23 May 2008 Link to this post

    To get the items to add to the grid when the page loads in NeedDataSource I put in:

    ataTable table = new DataTable();  
    table.Rows.Add(new object[] { "This is Text", "", "" });  
    table.Rows.Add(new object[] { "This is text2", "", "" });  
    table.Rows.Add(new object[] { "Another Item", "More Stuff", "" });  
    table.Rows.Add(new object[] { "Another Item", "A Description", "43" }); 

    Then in my Page_PreRender I put all the items in edit mode.

    What I would like to do is add in a RadEditor and also a RadNumeric box. When you're creating your columns and adding rows programicly, how do you add in the RadEditor and RadNumeric box?

    In the past I put it in my .aspx, but I was pulling the data from a SQL datasource so it was a little simpler.

    Is this the best way to go about this or is there a better way?



  3. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 May 2008 Link to this post

    Hi Brett,

    Go through the following help article.

    Programmatic creation


  4. Bruno
    Bruno avatar
    26 posts
    Member since:
    Feb 2009

    Posted 18 Feb 2009 Link to this post


    and what if I want to programmatic add a new column to an existing Detail Table?

    something like that.

                    How to insert more columns here, using the code behind? 

    I used this successfully to add to the master table, but I cant add to the detail table.

                    GridBoundColumn boundColumn; 
                    boundColumn = new GridBoundColumn(); 
                    boundColumn.DataField = "valor"
                    boundColumn.HeaderText = "Valor"
                    boundColumn.UniqueName = "valor"
                    boundColumn.DataFormatString = "{0:R$###,###.##}"
    How can I do the same with DETAILTABLES ?????

Back to Top