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

[Solved] Error while trying to Edit row - "Cannot unregister UpdatePanel with ID 'xxx' since it was not registered with the ScriptManager...

3 Answers 229 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hrvach
Top achievements
Rank 1
Hrvach asked on 04 Jan 2012, 02:22 PM
Hello!

Let me cut to the chase. My scenario is as follows: I have custom added fields to filter the RadGrid and filtering works perfectly. The problem comes when I want to edit record using EditForm inside RadGrid. It used to work fine, but then I had some problems with selecting the right row (I was always getting the wrong row selected) so this is what I did to fix it.

So, my RadGrid with filters looks like the one on the screenshot.

What I did is to use the Session which will help us to determine later if the filtered RadGrid DataSource was initiated or it was the default one.

protected void btnSearch_Click(object sender, EventArgs e)
    {
        Session["SearchKontakti"] = "1";
    }

After that I had to set PreRender with if loop to check for previously mentioned Session.

protected void gvKontakti_PreRender(object sender, EventArgs e)
    {
        int idKontakt = Convert.ToInt32(Request.QueryString["idk"]);
 
        if (Session["SearchKontakti"] == "1")
        {
            var kontakti = from k in db.Kontakt
                           select k;
 
            int idTipUsera = Convert.ToInt32(rcbTipUsera.SelectedValue);
            int idTvrtka = Convert.ToInt32(rcbTvrtka.SelectedValue);
 
            if (rcbTvrtka.SelectedValue != "0")
            {
                kontakti = kontakti.Where(k => k.idFirma == idTvrtka);
            }
 
            if (rcbTipUsera.SelectedValue != "0")
            {
                kontakti = kontakti.Where(k => k.idOvlasti == idTipUsera);
            }
 
            if (chkAktivan.Checked == true)
            {
                kontakti = kontakti.Where(k => k.Aktivan == true);
            }
            else
            {
                kontakti = kontakti.Where(k => k.Aktivan == false);
            }
 
            int idAuthKontakt = Convert.ToInt32(Session["authenticatedUI"]);
 
            if (idKontakt > 0 && idAuthKontakt == idKontakt)
            {
                gvKontakti.DataSource = from k in kontakti
                                        where k.idKontakt == idKontakt
                                        orderby k.Prezime, k.Ime
                                        select new { Tvrtka = k.Firma.Naziv, k.idKontakt, Naziv = k.Ime + " " + k.Prezime, Funkcija = k.Funkcija, k.Ime, k.Prezime, k.Tel1, k.Tel2, k.Mob1, k.Mob2, k.Email1, k.Email2, k.Fax, k.Adresa1, k.Adresa2, k.Adresa3, k.Grad, k.PostanskiBroj, k.Drzava, k.Biljeske, k.Aktivan, k.Username, k.Password };
            }
            else if (idKontakt > 0 && idAuthKontakt != idKontakt)
            {
                gvKontakti.DataSource = from k in kontakti
                                        where k.idKontakt == idKontakt
                                        orderby k.Prezime, k.Ime
                                        select new { Tvrtka = k.Firma.Naziv, k.idKontakt, Naziv = k.Ime + " " + k.Prezime, Funkcija = k.Funkcija, k.Ime, k.Prezime, k.Tel1, k.Tel2, k.Mob1, k.Mob2, k.Email1, k.Email2, k.Fax, k.Adresa1, k.Adresa2, k.Adresa3, k.Grad, k.PostanskiBroj, k.Drzava, k.Biljeske, k.Aktivan, k.Username, k.Password };
            }
            else
            {
                gvKontakti.DataSource = from k in kontakti
                                        orderby k.Prezime, k.Ime
                                        select new { Tvrtka = k.Firma.Naziv, k.idKontakt, Naziv = k.Ime + " " + k.Prezime, Funkcija = k.Funkcija, k.Ime, k.Prezime, k.Tel1, k.Tel2, k.Mob1, k.Mob2, k.Email1, k.Email2, k.Fax, k.Adresa1, k.Adresa2, k.Adresa3, k.Grad, k.PostanskiBroj, k.Drzava, k.Biljeske, k.Aktivan, k.Username, k.Password };
            }
 
            gvKontakti.DataBind();
        }
    }

So, this fixed my primary problem, but gave me another one. Some of my UserControls contain UpdatePanel and for each UserControl that has it whenever I try to clik Edit button from the RadGrid I receive the following message: "Cannot unregister UpdatePanel with ID 'UpdatePanel4' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported.

Parameter name: updatePanel"


What I'd like to know is how to fix it.

Regards,

Hrvoje

3 Answers, 1 is accepted

Sort by
0
Accepted
Mira
Telerik team
answered on 09 Jan 2012, 09:29 AM
Hello,

The cause of the issue is that there is an UpdatePanel / RadAjaxPanel in the usercontrols used as edit forms of the grid.
Please remove them and ajaxify the whole RadGrid.

I hope this helps.

Greetings,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Hrvach
Top achievements
Rank 1
answered on 12 Jan 2012, 01:30 AM
First of all I'd like to thank you for a response.

Ajaxifying RadGrid helped but then another problem occured. Whenever I try to open detail table when the RadGrid is filtered nothing happens. Something seems to be loading, but actually nothing happens.

Could that be connected with the PreRender event? The problem with RadGrid occured when I added standard controls (CheckBox, TextBox,...) that allowed me to manually filter RadGrid. After that I have to keep fixing dozen of errors or other bugs.

Regards,

Hrvoje
0
Accepted
Mira
Telerik team
answered on 16 Jan 2012, 01:34 PM
Hello,

Could you please try binding the grid using the approach from the following help topics and let me know whether this helps:
Advanced Data-binding (using NeedDataSource event)
Hierarchical data-binding using DetailTableDataBind event

I am looking forward to your reply.

Regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Hrvach
Top achievements
Rank 1
Answers by
Mira
Telerik team
Hrvach
Top achievements
Rank 1
Share this question
or