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

RadGrid inside Repeater and DataSource association

1 Answer 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
archimede
Top achievements
Rank 1
archimede asked on 08 Jul 2010, 11:27 AM
I'm associating by code a datasource to a grid inside a repeater control:

protected void Repeater1_PreRender(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in Repeater1.Items)
        {
            //Dinamically generate DataSource and associate it to Repeater Item
            ObjectDataSource ods = new ObjectDataSource();
            ods.ID = "automaticDS";
            ods.TypeName = "MachinaWeb.Services.BO_ConfigurazioneProgramma_Parametro";
            ods.SelectMethod = "getAll";
            ods.UpdateMethod = "updateParametro";
            ods.SelectParameters.Add("_idCultura", DbType.Int64, HiddenFieldIdCultura.Value);
            ods.SelectParameters.Add("_idAzienda", DbType.Int64, HiddenFieldIdAzienda.Value);
            ods.SelectParameters.Add("_idGruppoParametro", DbType.Int64, ((HiddenField)item.FindControl("HiddenFieldIdGruppo")).Value);
  
            RadGrid radGrid = (RadGrid)item.FindControl("RadGridParametriConfigurazione");
            radGrid.DataSource = ods;
            radGrid.DataBind();
        }
    }

Pagination and all works correctly. Instead trying an update it seems we have some problems. No error is thrown but i can exit from update only with cancel and in debug I see it does not reach the update function code.. Why? How can I solve this?

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 08 Jul 2010, 01:41 PM
Hi Archimede,

Note that simple data-binding through the DataBind() method can be used in simple scenarios which does not require complex operations like insert/delete/update, grouping, hierarchy relations, etc. You may take a look at the following articles on suggested way to populate RadGrid when using CRUD operations:

    - Advanced Data-binding (using NeedDataSource event)
    - Declarative DataSource

Greetings,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
archimede
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or