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

External Filter batchupdate grid comparing 2 columns with 2 combo boxes

2 Answers 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Magnus
Top achievements
Rank 2
Magnus asked on 08 Mar 2017, 04:03 AM

Hi guys,

I have a Batch Editing RadGrid like in this sample bellow and it has been working for years.  
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

I have been binding the radgrid via a ObjectDataSource.

<asp:ObjectDataSource ID="ods1" TypeName="Sensor.DAL" SelectMethod ="GetSensorBulkData" UpdateMethod="UpdateSensorBulkSettings" runat="server">

 

But now all I want is to add the functionality of cascading comboboxes in the top of the page to use as added filters comparing any sensor data column in the page.
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx

So I have added those and the filtering works fine but I had to modify my ObjectDataSource and now 

<asp:ObjectDataSource ID="ods1" TypeName="Sensor.DAL" UpdateMethod="UpdateSensorBulkSettings" runat="server">

so I have placed the original SelectMethod in Page_Load like this 

ods1.SelectMethod = "GetSensorBulkData";

and I have placed the filtered SelectMethod in Button1_Click the event for filtering using the Cascading Comboboxes like this

 protected void Button1_Click(object sender, EventArgs e) {
        Literal1.Text = string.Empty;

        if (RadComboBox1.SelectedIndex > 0 && RadComboBox2.SelectedIndex > 0 && RadComboBox3.SelectedIndex > 0) {
            Literal1.Text = string.Format(MessageTemplate, RadComboBox3.Text, RadComboBox2.Text, RadComboBox1.Text);

            string Lower = RadComboBox2.Text;
            string Higher = RadComboBox3.Text;
            ods1.TypeName = "DAL";
            ods1.SelectParameters.Clear();
            ods1.SelectParameters.Add("Low", TypeCode.String, Lower);
            ods1.SelectParameters.Add("High", TypeCode.String, Higher);
            ods1.SelectMethod = "GetSensorBulkDataCompared";
            }
}

The problem I have now is that I cant update my rows. and get the Message 

Sensor with ID '' Cannot be updated. Reason: ObjectDataSource 'ods1' could not find a non-generic method 'UpdateSensorBulkSettings' listing all my Update Parameters plus the parameter original_ID from nowhere so I add  OldValuesParameterFormatString="original_{0}" to my ObjectDataSource

<asp:ObjectDataSource ID="ods1" TypeName="Sensor.DAL"  OldValuesParameterFormatString="original_{0}"  UpdateMethod="UpdateSensorBulkSettings" runat="server"> like this and add original_id as an UPDATE parameter <asp:Parameter Name="original_id" Type="Int32"  />

Then I add the original_id to my UpdateMethod but I dont use it there I just trap it...to see if it works and NO no update and the same error message.

What have I missed?

Also for some reason I had a secondary issue with the the Cascading comboboxes they dont seem to want to play with the radgrid in the AJAX settings at all

<tr:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <tr:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <tr:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <tr:AjaxUpdatedControl ControlID="SavedChangesList" />
                </UpdatedControls>
            </tr:AjaxSetting>
            <tr:AjaxSetting AjaxControlID="RadComboBox1">
                <UpdatedControls>
                    <tr:AjaxUpdatedControl ControlID="RadComboBox2" />
                    <tr:AjaxUpdatedControl ControlID="RadComboBox3" />
                </UpdatedControls>
            </tr:AjaxSetting>
            <tr:AjaxSetting AjaxControlID="RadComboBox2">
                <UpdatedControls>
                    <tr:AjaxUpdatedControl ControlID="RadComboBox3" />
                </UpdatedControls>
            </tr:AjaxSetting>
        </AjaxSettings>
    </tr:RadAjaxManager>

RadComobox2 and 3 They look like they load but the never got populated. which I do just like in the demo from telerik 

protected void LoadCompare1()
    {
        RadComboBox2.DataTextField = "Title";
        RadComboBox2.DataValueField = "ID";
        RadComboBox2.DataSource = Data.GetSiteMatch();
        RadComboBox2.DataBind();
    }

 protected void LoadCompare2(int SiteId)
    {
        RadComboBox3.DataTextField = "Title";
        RadComboBox3.DataValueField = "ID";
        RadComboBox3.DataSource = Data.GetSiteMatchFiltered(SiteId);
        RadComboBox3.DataBind();
    }

the radgrid however sits inside a <tr:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1"> because it doesnt work outside it.

So Basically for testing purposes I have removed the AJAXsettings for the comboboxes so the entire page reloads after I change the values of Combobox 1 and 2 

Help!

2 Answers, 1 is accepted

Sort by
0
Magnus
Top achievements
Rank 2
answered on 08 Mar 2017, 08:27 AM

Ok I managed to figure out what caused the errors with at least the comboboxes. So they are working at 100% now.

I had an empty RadScriptBlock in the Content Head of my aspx page. I had a script there before which I had removed  and that caused the entire AJAX functionality to crash. I came to the conclusion because all AJAX functions seemed to malfunction so i used the Developer Tools in Chrome to find the Error which pointed me to CT100$Head something something.

But my main problem with the RadGrid still remains.

0
Magnus
Top achievements
Rank 2
answered on 08 Mar 2017, 10:04 AM

OK Seems I have solved everything but the UPDATE Both when filtered and unfiltered with the Comboboxes.

I still get this Error:

SENSOR with id 'value' cannot be updated. Reason ObjectDataSource 'ods1' could not find a non-generic method 'UpdateSensorBulkSettings' that has parameters: all my parameters + original_ID.

I assumed that I didnt have to do more with the UPDATE as I had left the UPDATE with parameters on the ASPX page

<asp:ObjectDataSource ID="ods1" TypeName="DAL" OldValuesParameterFormatString="original_{0}" UpdateMethod="UpdateSensorBulkSettings" runat="server">
        <UpdateParameters>
            <asp:Parameter Name="Id" Type="Int32" />
            ..... ALL MY PARAMETERS
            <asp:Parameter Name="Username" Type="String" />
            <asp:Parameter Name="original_id" Type="Int32" />
        </UpdateParameters>
    </asp:ObjectDataSource>

Im guessing thats a mistake, So in what event do I have to wire up the updatestatement in CodeBehind and after I have done that can I remove the ObjectDataSource from the ASPX page and only have it in CodeBehind?

Tags
Grid
Asked by
Magnus
Top achievements
Rank 2
Answers by
Magnus
Top achievements
Rank 2
Share this question
or