Jump to content
Software FX Community

Add Grid Row Programmatically


Recommended Posts

If the grid is bound to data, you cannot add items as the grid will automatically clear them when binding.  Adding items manually only makes sense for unbound grids. Do you need to work with an unbound Grid? If that is the case, first you need to create grid fields and then populates them programmatically.

The easiest way to accomplish this:

1. Drop an empty Grid FX object from the toolbar into your web page.

2. Select the Grid FX object.

3. If the Properties Window is not displayed, go to View menu and select it or press F4 .

4. In the properties window, expand the Fields category.

5. Click on the More button and the GridField Collection Editor appears

6. Select the field type and Add as many fields as you need. In this example we added two TextFields: FirstName, LastName and one NumberField: Salary

7. Once the grid shows a column for every field added, you just need to add some code to populate the grid:

protected void Page_Load(object sender, EventArgs e)


  if (!IsPostBack)


  if (Grid1.Items.Count == 0)


  GridItem item = new GridItem();


  item.DataValues.Add(Grid1.Fields["Lastname"], "Jordan");

  item.DataValues.Add(Grid1.Fields["Salary"], 1000);


  item = new GridItem();

  item.DataValues.Add(Grid1.Fields["Firstname"], "Tiger");

  item.DataValues.Add(Grid1.Fields["Lastname"], "Woods");

  item.DataValues.Add(Grid1.Fields["Salary"], 2000);






Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...