Blog Home  Home Feed your aggregator (RSS 2.0)  
Manu 1 - Telerik 0 - Manuel Abadia's ASP.NET stuff
 
# Thursday, 26 July 2007

A couple of days ago a customer told me that he was using the ExtendedObjectDataSource without problems with telerik’s RADGrid for quite some time. However, when he tried to bind two ExtendedObjectDataSource controls using the master/detail mode of the RADGrid, it didn’t work. He asked the Telerik guys for help on this and they send them an example telling him that it was working with the ObjectDataSource, so it was a problem with the ExtendedObjectDataSource.

I found a problem in their test case so I told them that it wasn’t my fault although I couldn’t understand why it did work for the ObjectDataSource.

They modified their test case to overcome the problem I exposed, so the new test case worked for the ObjectDataSource and it didn’t work for the ExtendedObjectDataSource. Something really strange was happening.


I spent some time carefully reviewing my code but I didn’t found any problem. I had no previous experience with the RADGrid (an excellent control BTW) but I loaded the evaluation version in reflector and I stumbled upon the following code:


 

protected virtual void FilterDetailDataSource()

{

    this.UseDataSource = true;

    GridDetailTableDataBindEventArgs args = new GridDetailTableDataBindEventArgs(this.OwnerGrid, this);

    base.RaiseBubbleEvent(this, args);

    if (!args.Canceled && (this.ParentTableRelation.Count > 0)) {

        if (!base.IsBoundUsingDataSourceID) {

            this.SetDataSourceFilter();

        } else {

            ParameterCollection selectParameters = null;

            DataSourceControl control = (DataSourceControl)GridDataSourceControlHelper.FindControl(this, this.DataSourceID);

            if (control is SqlDataSource) {

                selectParameters = (control as SqlDataSource).SelectParameters;

            } else if (control is ObjectDataSource) {

                selectParameters = (control as ObjectDataSource).SelectParameters;

            }

            if ((selectParameters != null) && (selectParameters.Count > 0)) {

                foreach (Parameter parameter in selectParameters) {

                    GridRelationFields fields = null;

                    foreach (GridRelationFields fields2 in this.ParentTableRelation) {

                        if (parameter.Name.ToUpper() == fields2.DetailKeyField.ToUpper()) {

                            fields = fields2;

                            break;

                        }

                    }

                    if (fields != null) {

                        GridDataKeyArray dataKeyValues = this.ParentItem.OwnerTableView.DataKeyValues;

                        if (dataKeyValues.Count <= 0) {

                            continue;

                        }

                        DataKey key = dataKeyValues[this.ParentItem.ItemIndex];

                        object obj2 = key[fields.MasterKeyField];

                        if (obj2 == null) {

                            continue;

                        }

                        parameter.DefaultValue = obj2.ToString();

                    }

                }

            }

        }

    }

}

 

If you know about DataSource controls and their infrastructure the problem is clear. Telerik’s RADGrid gets the control bound to the grid (using the DataSourceID property). If it is a SqlDataSource or an ObjectDataSource, it gets the SelectParameters. After that they try to find a parameter in the SelectParameters that matches the field used to traverse from the master object to the detail object and if they found it, they set the DefaultValue of the parameter to the associated key.

However, they are ignoring ALL DataSource controls but the SqlDataSource and ObjectDataSource. This is not a nice way to play with others!
 
I told them to please add more generic code to support more data sources. Something like adding a property SelectParametersPropertyName with a default value of “SelectParameters” and using reflection to get the property from the control will do the trick. I don’t know how they have changed it but at least they sent a fixed private version to my customer. With a bit of luck they'll add the modification to the next public release.

I can’t compare with Telerik in any way as they are one of the most important component vendors in the .NET market, they have an amazing quantity of controls and they have a lot of people working for them… Anyway, nothing like being right against Telerik to make my day.

Thursday, 26 July 2007 23:46:48 (Romance Daylight Time, UTC+02:00)  #    Comments [2]   ASP.NET  | 
Copyright © 2018 Manuel Abadia. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.