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

2 posts, 0 answers
  1. Ko
    Ko avatar
    1 posts
    Member since:
    Dec 2010

    Posted 23 Dec 2010 Link to this post

    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];
                }
  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 24 Dec 2010 Link to this post

    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.
Back to Top