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

I got error when i try to retrieve data from excel file in using ajax setting update control

1 Answer 37 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Ko
Top achievements
Rank 1
Ko asked on 24 Dec 2010, 03:39 AM
Hi,

I got error when i try to retrieve data from excel file in using ajax setting update control. When I do not use ajax setting update control, I can retrieve data from excel.

Please kindly suggest me any config i need to change or RadAjax is not supporting data retrieving from excel ?

my codes are as follow.

 
       <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            onajaxrequest="RadAjaxManager1_AjaxRequest" clientevents-onrequeststart="startProgress" clientevents-onresponsereceived="hideProgress">
            <clientevents onrequeststart="startProgress" />
                     <AjaxSettings>
                                                                 
                       <telerik:AjaxSetting AjaxControlID="btnUpload">
                  
                            <UpdatedControls>
                                
                                           <telerik:AjaxUpdatedControl ControlID="grvServiceList" LoadingPanelID="RadAjaxLoadingPanel1" />
                           
                            </UpdatedControls>
                  
                        </telerik:AjaxSetting>
                        
                    </AjaxSettings>
               </telerik:RadAjaxManager>  

using (OleDbConnection connExcel = new OleDbConnection(strExlConn))
            {              

                OleDbCommand cmdExcel = new OleDbCommand();
                OleDbDataAdapter da = new OleDbDataAdapter();
                cmdExcel.Connection = connExcel;

                connExcel.Open();
                DataTable dtExcelSchema;
                dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                connExcel.Close();

                //string sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString(); //dtExcelSchema.Rows[0]["TABLE_NAME"];

                string sheetName = string.Empty;

                for (int i = 0; i < dtExcelSchema.Rows.Count; i++)
                {
                    sheetName = sheetName + ", " + dtExcelSchema.Rows[i]["TABLE_NAME"].ToString();
                }

                DataSet ds = new DataSet();

                string SheetName = "Sheet1$";//dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();

                cmdExcel.CommandText = "SELECT '" + JobId + "' AS [JobId], * From [" + SheetName + "]";

                da.SelectCommand = cmdExcel;               

                da.Fill(ds);


                if (cmdExcel != null) cmdExcel.Dispose();
                if (da != null) da.Dispose();
                if (connExcel != null) connExcel.Dispose();               

                //ds.Clear();
                //ds.Dispose();

                return ds.Tables[0];
            }

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Dec 2010, 12:17 PM
Hello Ko,

Could you please post the rest of your code? I noticed that you wired the client-side OnRequestStart event two times.

In the meantime I recommend that you try to modify your ajax settings this way:
<AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="btnUpload">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="grvServiceList" LoadingPanelID="RadAjaxLoadingPanel1" />
        </UpdatedControls>
    </telerik:AjaxSetting>
    <telerik:AjaxSetting AjaxControlID="grvServiceList">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="grvServiceList" LoadingPanelID="RadAjaxLoadingPanel1" />
        </UpdatedControls>
    </telerik:AjaxSetting>
</AjaxSettings>

Note that if RadAjaxManager updates RadGrid you should also add the following setting:
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="grvServiceList" LoadingPanelID="RadAjaxLoadingPanel1" />
    </UpdatedControls>
</telerik:AjaxSetting>

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Ajax
Asked by
Ko
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or