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

Add items to Grid on Load

3 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 1
Brett asked on 22 May 2008, 05:13 PM

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.

Thanks,

Brett

3 Answers, 1 is accepted

Sort by
0
Brett
Top achievements
Rank 1
answered on 23 May 2008, 05:01 AM
To get the items to add to the grid when the page loads in NeedDataSource I put in:

ataTable table = new DataTable();  
table.Columns.Add("Item");  
table.Columns.Add("Description");  
table.Columns.Add("Cost");  
 
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?

Thanks,

Brett

0
Shinu
Top achievements
Rank 2
answered on 23 May 2008, 06:03 AM

Hi Brett,

Go through the following help article.

Programmatic creation

Shinu


0
Bruno
Top achievements
Rank 1
answered on 18 Feb 2009, 06:35 PM
Hello,

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

something like that.

<MasterTableView> 
   <detailtables> 
        <Gridtableview> 
 
            <columns> 
              <gridboundcolumn></gridboundcolumn
              <gridboundcolumn></gridboundcolumn
              <gridboundcolumn></gridboundcolumn
 
                How to insert more columns here, using the code behind? 
 
            <columns> 
        <gridtableview> 
 
   </detailtables> 
 
<columns>......</columns> 
<MastertableView> 

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

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

Thanxs
Tags
Grid
Asked by
Brett
Top achievements
Rank 1
Answers by
Brett
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Bruno
Top achievements
Rank 1
Share this question
or