Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint Telerik RadGrid导出到Excel。在'之前缺少操作数=';操作人员_Sharepoint_Telerik_Web Parts_Radgrid - Fatal编程技术网

Sharepoint Telerik RadGrid导出到Excel。在'之前缺少操作数=';操作人员

Sharepoint Telerik RadGrid导出到Excel。在'之前缺少操作数=';操作人员,sharepoint,telerik,web-parts,radgrid,Sharepoint,Telerik,Web Parts,Radgrid,我发现了错误 “=”运算符之前缺少操作数。 当我尝试导出时,代码在网格中运行良好。 下面是web部件的代码。该错误仅在重新绑定时发生。它在网格本身中运行良好。有没有办法缩小它所犯错误的范围? 我愿意为这个问题的支持/解决方案付费,我只需要它工作 [Guid("5fbe4ccf-4d90-476b-af77-347de4e1176c")] public class ParentChildGrid : Microsoft.SharePoint.WebPartPages.WebPart { #r

我发现了错误 “=”运算符之前缺少操作数。 当我尝试导出时,代码在网格中运行良好。 下面是web部件的代码。该错误仅在重新绑定时发生。它在网格本身中运行良好。有没有办法缩小它所犯错误的范围? 我愿意为这个问题的支持/解决方案付费,我只需要它工作

[Guid("5fbe4ccf-4d90-476b-af77-347de4e1176c")]
public class ParentChildGrid : Microsoft.SharePoint.WebPartPages.WebPart

{


#region
Variables
private bool _error = false;
private string _PageSize = null;
private string _ParentList = null;
private string _ParentView = null;
private string _ParentIDField = null;
private string _FirstChildList = null;
private string _FirstChildView = null;
private string _FirstChildIDField = null;
private string _FirstChildParentIDField = null;
private string _SecondChildList = null;
private string _SecondChildView = null;
private string _SecondChildIDField = null;
private string _SecondChildParentIDField = null;
protected ScriptManager scriptManager;
protected RadAjaxManager ajaxManager;
protected Panel panel;
protected SPView oView;
protected RadGrid oGrid = new RadGrid();
protected Label label;
protected DataTable ParentDataTable;
protected DataTable Child1DataTable;
protected DataTable Child2DataTable;
protected Button cmdExport = new Button();

#endregion
#region
Properties
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.
Category("Parent Child Properties")]
[WebDisplayName("Items Per Page")]
[WebDescription("# of items to include in each page.")]
public string PageSize
{
    get

    {
        if (_PageSize == null)
        {
            _PageSize = "100";
        }
        return _PageSize.Trim();
    }
    set { _ParentList = value.Trim(); }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.
Category("Parent Child Properties")]
[WebDisplayName("ParentList")]
[WebDescription("Parent List in Grid View")]
public string ParentList
{
    get

    {
        if (_ParentList == null)
        {
            _ParentList = "";
        }
        return _ParentList.Trim();
    }
    set { _ParentList = value.Trim(); }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.Category("Parent Child Properties")]
[WebDisplayName("ParentView")]
[WebDescription("View for Parent List")]
public string ParentView
{
    get

    {
        if (_ParentView == null)
        {
            _ParentView = "";
        }
        return _ParentView.Trim();
    }
    set { _ParentView = value.Trim(); }
}
[
Personalizable(PersonalizationScope.Shared)]
[
WebBrowsable(true)]
[System.ComponentModel.
Category("Parent Child Properties")]
[
WebDisplayName("ParentIDField")]
[
WebDescription("ID Field in Parent List")]
public string ParentIDField
{
    get

    {
        if (_ParentIDField == null)
        {
            _ParentIDField = "";
        }
        return _ParentIDField.Trim();
    }
    set { _ParentIDField = value.Trim(); }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.
Category("Parent Child Properties")]
[WebDisplayName("FirstChildList")]
[WebDescription("FirstChildList Name")]
public string FirstChildList
{
    get

    {
        if (_FirstChildList == null)
        {
            _FirstChildList = "";
        }
        return _FirstChildList.Trim();
    }
    set { _FirstChildList = value.Trim(); }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.Category("Parent Child Properties")]
[WebDisplayName("FirstChildView")]
[WebDescription("First Child View Name")]
public string FirstChildView
{
    get

    {
        if (_FirstChildView == null)
        {
            _FirstChildView = "";
        }
        return _FirstChildView.Trim();
    }
    set { _FirstChildView = value.Trim(); }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.Category("Parent Child Properties")]
[WebDisplayName("FirstChildIDField")]
[WebDescription("First Child ID Field (Tyically ID)")]
public string FirstChildIDField
{
    get

    {
        if (_FirstChildIDField == null)
        {
            _FirstChildIDField = "";
        }
        return _FirstChildIDField.Trim();
    }
    set { _FirstChildIDField = value.Trim(); }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.Category("Parent Child Properties")]
[WebDisplayName("FirstChildParentIDField")]
[WebDescription("First Child Parent ID Field")]
public string FirstChildParentIDField
{
    get

    {
        if (_FirstChildParentIDField == null)
        {
            _FirstChildParentIDField = "";
        }
        return _FirstChildParentIDField.Trim();
    }
    set { _FirstChildParentIDField = value.Trim(); }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.
Category("Parent Child Properties")]
[WebDisplayName("SecondChildList")]
[WebDescription("Second Child List")]
public string SecondChildList
{
    get
    {
        if (_SecondChildList == null)
        {
            _SecondChildList = "";
        }
        return _SecondChildList.Trim();
    }
    set { _SecondChildList = value.Trim(); }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.
Category("Parent Child Properties")]
[WebDisplayName("SecondChildView")]
[
WebDescription("Second Child View")]
public string SecondChildView
{
    get
    {
        if (_SecondChildView == null)
        {
            _SecondChildView = "";
        }
        return _SecondChildView.Trim();
    }
    set { _SecondChildView = value.Trim(); }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.
Category("Parent Child Properties")]
[WebDisplayName("SecondChildIDField")]
[WebDescription("Second Child ID Field (Typically ID)")]
public string SecondChildIDField
{
    get

    {
        if (_SecondChildIDField == null)
        {
            _SecondChildIDField = "";
        }
        return _SecondChildIDField.Trim();
    }
    set { _SecondChildIDField = value.Trim(); }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.Category("Parent Child Properties")]
[WebDisplayName("SecondChildParentIDField")]
[WebDescription("Second Child ID Field")]
public string SecondChildParentIDField
{
    get

    {
        if (_SecondChildParentIDField == null)
        {
            _SecondChildParentIDField = "";
        }
        return _SecondChildParentIDField.Trim();
    }
    set { _SecondChildParentIDField = value.Trim(); }
}

#endregion

private const string ByeByeIncludeScriptKey = "myByeByeIncludeScript";
private const string EmbeddedScriptFormat = "<script language=javascript>function ByeBye(){ alert('Test Code'); }</script> ";
private const string DisableAjaxScriptKey = "myDisableAjaxIncludeScript";
private const string DisableAjaxForExport = "<script language=javascript>function onRequestStart(sender, args) { if (args.get_eventTarget().indexOf(\"cmdExport\") >= 0);args.set_enableAjax(false);alert('Ajax Disabled'); }</script>";
private void WebPart_ClientScript_PreRender(object sender , System.EventArgs e )
{
    if (!Page.IsClientScriptBlockRegistered(ByeByeIncludeScriptKey))
    Page.RegisterClientScriptBlock(ByeByeIncludeScriptKey,
    EmbeddedScriptFormat);
    if (!Page.IsClientScriptBlockRegistered(DisableAjaxScriptKey))
    Page.RegisterClientScriptBlock(DisableAjaxScriptKey,
    DisableAjaxForExport);
    //ajaxManager.ClientEvents.OnRequestStart = "onRequestStart";

}
public ParentChildGrid()
{
    this.ExportMode = WebPartExportMode.All;
    this.PreRender += new EventHandler(WebPart_ClientScript_PreRender);
}
private void onRequestStart()
{
    ajaxManager.EnableAJAX =
    false;
}
protected override void OnInit(EventArgs e)
{
    try

    {
        base.OnInit(e);
        Page.ClientScript.RegisterStartupScript(
        typeof(ParentChildGrid), this.ID, "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;", true);
        if (this.Page.Form != null)
        {
            string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
            if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();")
            {
                this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
            }
        }
        scriptManager =
        ScriptManager.GetCurrent(this.Page);
        if (scriptManager == null)
        {
            scriptManager =
            new RadScriptManager();
            this.Page.Form.Controls.AddAt(0, scriptManager);
        }
        scriptManager.RegisterPostBackControl(cmdExport);
    }
    catch (Exception ex)
    {
        HandleException(ex);
    }
}
protected override void OnLoad(EventArgs e)
{
    ScriptManager.GetCurrent(Page).RegisterPostBackControl(cmdExport);
    if (!_error)
    {
        try

        {
            base.OnLoad(e);
            this.EnsureChildControls();
            base.OnLoad(e);
            if (_ParentList != null)
            {
                if (_ParentList != "")
                {
                    panel =
                    new Panel();
                    panel.ID =
                    "Panel1";
                    this.Controls.Add(panel);
                    oGrid =
                    new RadGrid();
                    DefineComplexGrid();
                    oGrid.GridExporting +=
                    new OnGridExportingEventHandler(oGrid_GridExporting);
                    panel.Controls.Add(oGrid);
                    //DefineSimpleMasterDetail();

                    cmdExport.Click +=
                    new EventHandler(cmdExport_Click);
                    cmdExport.Text =
                    "Export";
                    Button cmdExpandAll = new Button();
                    cmdExpandAll.Text =
                    "Expand All";
                    cmdExpandAll.Click +=
                    new EventHandler(cmdExpandAll_Click);
                    panel.Controls.Add(cmdExpandAll);
                    ajaxManager =
                    RadAjaxManager.GetCurrent(this.Page);
                    if (ajaxManager == null)
                    {
                        ajaxManager =
                        new RadAjaxManager();
                        ajaxManager.ID =
                        "RadAjaxManager1";
                        Controls.Add(ajaxManager);
                        this.Page.Items.Add(typeof(RadAjaxManager), ajaxManager);
                    }
                    ajaxManager.AjaxSettings.AddAjaxSetting(oGrid, panel);
                    panel.Controls.Add(cmdExport);
                    ajaxManager.AjaxRequest +=
                    new RadAjaxControl.AjaxRequestDelegate(ajaxManager_AjaxRequest);
                    this.Controls.Add(new LiteralControl("<br><br>&lt;input class='ms-SPButton' value=\'Test Code\' type=button onclick=\"ByeBye();\" &gt;"));
                    ajaxManager.ClientEvents.OnRequestStart =
                    "onRequestStart";
                }
            }
        }
        catch (Exception ex)
        {
            HandleException(ex);
        }
    }
}
void oGrid_GridExporting(object source, GridExportingArgs e)
{
    //throw new NotImplementedException();

}
void ajaxManager_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
    ajaxManager.EnableAJAX =
    false;
}
void cmdExpandAll_Click(object sender, EventArgs e)
{
    try

    {
        foreach (GridItem item in oGrid.MasterTableView.Items)
        {
            item.Expanded =
            true;
        }
    }
    catch (Exception ex)
    {
        HandleException(ex);
    }
}
void cmdExport_Click(object sender, EventArgs e)
{
    try

    {
        ajaxManager.ClientEvents.OnRequestStart =
        "onRequestStart";
        oGrid.ExportSettings.ExportOnlyData =
        true;
        oGrid.ExportSettings.IgnorePaging =
        true;
        oGrid.ExportSettings.OpenInNewWindow =
        true;
        oGrid.MasterTableView.HierarchyDefaultExpanded =
        true;
        if (FirstChildList.Trim() != "")
        oGrid.MasterTableView.DetailTables[0].HierarchyDefaultExpanded =
        true;
        if (SecondChildList.Trim() != "")
        oGrid.MasterTableView.DetailTables[1].HierarchyDefaultExpanded =
        true;
        oGrid.Rebind();
        oGrid.MasterTableView.ExportToExcel();
    }
    catch (Exception ex)
    {
        HandleException(ex);
    }
}
//private void DefineSimpleGrid()

//{

    // try

    // {

        // oGrid.ID = "Master";

        // oGrid.PageSize = 10;

        // oGrid.AllowPaging = true;

        // oGrid.AllowSorting = true;

        // oGrid.Skin = "WebBlue";

        // oGrid.GroupingEnabled = true;

        // oGrid.NeedDataSource += new GridNeedDataSourceEventHandler(oGrid_NeedDataSource);

        // oGrid.ShowStatusBar = true;

        // oGrid.ShowGroupPanel = true;

        // oGrid.GroupingEnabled = true;

        // oGrid.ClientSettings.AllowDragToGroup = true;

        // oGrid.ClientSettings.AllowColumnsReorder = true;

    // }

    // catch (Exception ex)

    // {

        // HandleException(ex);

    // }

//}

private DataTable GetDataTable(String cListName, String ViewName)
{
    try

    {
        SPList list = SPContext.Current.Web.Lists[cListName];
        SPView view = list.Views[ViewName];
        SPListItemCollection items = list.GetItems(view);
        if (items != null)
        {
            if (items.Count &gt; 0)
            return items.GetDataTable();
        }
    }
    catch (Exception ex)
    {
        HandleException(ex);
    }
    return null;
}
//private void DefineSimpleMasterDetail()

//{

    // try

    // {

        // oGrid.MasterTableView.DataKeyNames = new string[] { "ID" };

        // oGrid.Skin = "Default";

        // oGrid.Width = Unit.Percentage(100);

        // oGrid.PageSize = 5;

        // oGrid.AllowPaging = true;

        // oGrid.MasterTableView.PageSize = 15;

        // oGrid.MasterTableView.DataSource = GetDataTable(_ParentList, _ParentView);

        // GridTableView tableViewOrders = new GridTableView(oGrid);

        // tableViewOrders.DataSource = GetDataTable(_FirstChildList, _FirstChildView);

        // tableViewOrders.DataKeyNames = new string[] { _ParentIDField };

        // GridRelationFields relationFields = new GridRelationFields();

        // relationFields.MasterKeyField = _FirstChildIDField;

        // relationFields.DetailKeyField = _FirstChildParentIDField;

        // tableViewOrders.ParentTableRelation.Add(relationFields);

        // oGrid.MasterTableView.DetailTables.Add(tableViewOrders);

    // }

    // catch (Exception ex)

    // {

        // HandleException(ex);

    // }

//}

private void DefineComplexGrid()
{
    try

    {
        oGrid.ID =
        "RadGrid1";
        //oGrid.Width = Unit.Percentage(98);

        oGrid.PageSize =
        Convert.ToInt32(PageSize);
        oGrid.AllowPaging =
        true;
        oGrid.AllowSorting =
        true;
        oGrid.PagerStyle.Mode =
        GridPagerMode.NextPrevAndNumeric;
        oGrid.ShowStatusBar =
        true;
        oGrid.ClientSettings.Resizing.AllowColumnResize =
        true;
        oGrid.DetailTableDataBind +=
        new GridDetailTableDataBindEventHandler(oGrid_DetailTableDataBind);
        oGrid.NeedDataSource +=
        new GridNeedDataSourceEventHandler(oGrid_NeedDataSource);
        oGrid.ColumnCreated +=
        new GridColumnCreatedEventHandler(oGrid_ColumnCreated);
        oGrid.MasterTableView.Name = _ParentList;
        if (_FirstChildList != "" || _SecondChildList != "")
        {
            oGrid.MasterTableView.PageSize =
            Convert.ToInt32(PageSize);
            oGrid.MasterTableView.DataKeyNames =
            new string[] { _ParentIDField };
            oGrid.MasterTableView.HierarchyLoadMode =
            GridChildLoadMode.ServerOnDemand;
        }
        if (_FirstChildList != "")
        {
            GridTableView tableViewFirstChild = new GridTableView(oGrid);
            tableViewFirstChild.Width =
            Unit.Percentage(100);
            tableViewFirstChild.HierarchyLoadMode =
            GridChildLoadMode.ServerOnDemand;
            tableViewFirstChild.DataKeyNames =
            new string[] { _FirstChildIDField };
            tableViewFirstChild.Name = _FirstChildList;
            GridRelationFields FirstChildrelationFields = new GridRelationFields();
            FirstChildrelationFields.MasterKeyField = _ParentIDField;
            FirstChildrelationFields.DetailKeyField = _FirstChildParentIDField;
            tableViewFirstChild.ParentTableRelation.Add(FirstChildrelationFields);
            tableViewFirstChild.Caption = _FirstChildList;
            oGrid.MasterTableView.DetailTables.Add(tableViewFirstChild);
        }
        if (_SecondChildList != "")
        {
            GridTableView tableViewSecondChild = new GridTableView(oGrid);
            tableViewSecondChild.Width =
            Unit.Percentage(100);
            tableViewSecondChild.HierarchyLoadMode =
            GridChildLoadMode.ServerOnDemand;
            tableViewSecondChild.DataKeyNames =
            new string[] { _SecondChildIDField };
            tableViewSecondChild.Name = _SecondChildList;
            GridRelationFields SecondChildrelationFields = new GridRelationFields();
            SecondChildrelationFields.MasterKeyField = _ParentIDField;
            SecondChildrelationFields.DetailKeyField = _SecondChildParentIDField;
            tableViewSecondChild.Caption = _SecondChildList;
            tableViewSecondChild.ParentTableRelation.Add(SecondChildrelationFields);
            oGrid.MasterTableView.DetailTables.Add(tableViewSecondChild);
        }
        oGrid.ShowStatusBar =
        true;
        oGrid.ShowGroupPanel =
        true;
        oGrid.GroupingEnabled =
        true;
        oGrid.ClientSettings.AllowDragToGroup =
        true;
        oGrid.ClientSettings.AllowColumnsReorder =
        true;
        oGrid.Skin =
        "Web20";
    }
    catch (Exception ex)
    {
        HandleException(ex);
    }
}
void oGrid_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
    try

    {
        //if (e.Column.HeaderText == "ID" || e.Column.HeaderText == "Created")

        //{

            // e.Column.Display = false;

            // return;

        //}

        String cOwnerTable = "";
        cOwnerTable = e.OwnerTableView.Name;
        if (cOwnerTable.Trim() != "" && e.Column.HeaderText != "" && e.Column.HeaderText != _FirstChildParentIDField && e.Column.HeaderText != _SecondChildParentIDField)
        {
            SPList CurrentList = SPContext.Current.Web.Lists[e.OwnerTableView.Name];
            e.Column.HeaderText = GetFieldDisplayName(e.Column.HeaderText, CurrentList);
            SPField oField = CurrentList.Fields[e.Column.HeaderText];
            GridBoundColumn col = (GridBoundColumn)e.Column;
            switch (oField.Type)
            {
                case SPFieldType.Currency:
                col.DataFormatString =
                "{0:C}";
                break;
                case SPFieldType.DateTime:
                SPFieldDateTime oDateTime = (SPFieldDateTime)oField;
                if (oDateTime.DisplayFormat == SPDateTimeFieldFormatType.DateOnly)
                col.DataFormatString =
                "{0:d}";
                break;
                default:
                break;
            }
        }
    }
    catch (Exception ex)
    {
        HandleException(ex);
    }
}
private DataTable GetChildDataTable(GridDetailTableDataBindEventArgs e, String cChildListName, String cChildView,String cParentIDField)
{
    try

    {
        GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;
        SPList FirstChildList = SPContext.Current.Web.Lists[cChildListName];
        SPView oView = FirstChildList.Views[cChildView];
        String cContractID = parentItem[_ParentIDField].Text;
        SPQuery oChildQuery = new SPQuery();
        if (Occurs(cParentIDField, oView.Query) == 2)
        {
            String cNewQuery = oView.Query;
            Int32 iPos = cNewQuery.IndexOf(cParentIDField) + cParentIDField.Length;
            String cPartOne = cNewQuery.Substring(0,cNewQuery.IndexOf(cParentIDField, iPos));
            String cPartTwo = cNewQuery.Substring(cNewQuery.IndexOf(cParentIDField, iPos) + cParentIDField.Length);
            cNewQuery = cPartOne + cContractID + cPartTwo;
            oChildQuery.Query = cNewQuery;
            oChildQuery.Query =
            "&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='" + cParentIDField + "' /&gt;&lt;Value Type='Text'&gt;" + cContractID + "&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;";
        }
        else

        {
            oChildQuery.Query =
            "&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='" + cParentIDField + "' /&gt;&lt;Value Type='Text'&gt;" + cContractID + "&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;";
        }
        SPViewFieldCollection oViewFields = oView.ViewFields;
        oViewFields.Add(cParentIDField);
        String cViewFields = oViewFields.SchemaXml;
        oChildQuery.ViewFields = cViewFields;
        SPListItemCollection items = FirstChildList.GetItems(oChildQuery);
        if (items != null)
        {
            if (items.Count &gt; 0)
            {
                return items.GetDataTable();
            }
        }
    }
    catch (Exception ex)
    {
        //HandleException(ex);

    }
    return null;
}
void oGrid_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
{
    try

    {
        GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;
        if (parentItem.Edit)
        {
            return;
        }
        if (e.DetailTableView.Name == _FirstChildList)
        {
            Child1DataTable = GetChildDataTable(e, _FirstChildList, _FirstChildView, _FirstChildParentIDField);
            e.DetailTableView.DataSource = Child1DataTable;
        }
        if (e.DetailTableView.Name == _SecondChildList)
        {
            Child2DataTable = GetChildDataTable(e, _SecondChildList, _SecondChildView, _SecondChildParentIDField);
            e.DetailTableView.DataSource = Child2DataTable;
        }
    }
    catch (Exception ex)
    {
        HandleException(ex);
    }
}
void oGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
    try

    {
        if (!e.IsFromDetailTable)
        {
            SPList ParentList = SPContext.Current.Web.Lists[_ParentList];
            oView = ParentList.Views[_ParentView];
            SPQuery ParentQuery = new SPQuery();
            ParentQuery.Query = oView.Query;
            ParentQuery.RowLimit = 100000;
            ParentQuery.ViewFields = oView.ViewFields.SchemaXml;
            SPListItemCollection oItems = SPContext.Current.Web.Lists[_ParentList].GetItems(ParentQuery);
            ParentDataTable = oItems.GetDataTable();
            oGrid.DataSource = ParentDataTable;
        }
    }
    catch (Exception ex)
    {
        HandleException(ex);
    }
}
private string GetFieldDisplayName(String cInternalName, SPList oList)
{
    try
    {
        foreach (SPField field in oList.Fields)
        {
            if (field.InternalName == cInternalName)
            return field.Title;
        }
    }
    catch (Exception ex)
    {
        HandleException(ex);
    }
    return cInternalName;
}
private Int32 Occurs(String SearchFor, String SearchIn)
{
    Int32 Count = 0;
    Int32 iPos = 0;
    try
    {
        while (SearchIn.IndexOf(SearchFor, iPos) != -1)
        {
            Count++;
            iPos = SearchIn.IndexOf(SearchFor, iPos) + 1;
        }
    }
    catch (Exception ex)
    {
        HandleException(ex);
    }
    return Count;
}
private void HandleException(Exception ex)
{
    this._error = true;
    try
    {
        this.Controls.Clear();
        this.Controls.Add(new LiteralControl(ex.Message));
    }
    catch
    {
    }
}
} //End Class
[Guid(“5fbe4ccf-4d90-476b-af77-347de4e1176c”)]
公共类ParentChildGrid:Microsoft.SharePoint.WebPartPages.WebPart
{
#区域
变量
private bool_error=false;
私有字符串_PageSize=null;
私有字符串_ParentList=null;
私有字符串_ParentView=null;
私有字符串_ParentIDField=null;
私有字符串_FirstChildList=null;
私有字符串_FirstChildView=null;
私有字符串_FirstChildIDField=null;
私有字符串_FirstChildParentIDField=null;
私有字符串_SecondChildList=null;
私有字符串_SecondChildView=null;
私有字符串_SecondChildIDField=null;
私有字符串_SecondChildParentIDField=null;
受保护的ScriptManager ScriptManager;
受保护的RadAjaxManager ajaxManager;
保护面板;
受保护的Spoview;
受保护的RadGrid oGrid=新RadGrid();
受保护标签;
受保护的数据表ParentDataTable;
受保护的数据表child1数据表;
受保护的DataTable Child2DataTable;
受保护的按钮cmdExport=新建按钮();
#端区
#区域
性质
[可个性化(PersonalizationScope.Shared)]
[可浏览网页(正确)]
[System.ComponentModel。
类别(“父子属性”)]
[WebDisplayName(“每页项目”)]
[WebDescription(“#每个页面中包含的项目”)]
公共字符串页面大小
{
得到
{
如果(_PageSize==null)
{
_PageSize=“100”;
}
返回PageSize.Trim();
}
设置{u ParentList=value.Trim();}
}
[可个性化(PersonalizationScope.Shared)]
[可浏览网页(正确)]
[System.ComponentModel。
类别(“父子属性”)]
[WebDisplayName(“父列表”)]
[WebDescription(“网格视图中的父列表”)]
公共字符串父列表
{
得到
{
if(_ParentList==null)
{
_父列表=”;
}
return_ParentList.Trim();
}
设置{u ParentList=value.Trim();}
}
[可个性化(PersonalizationScope.Shared)]
[可浏览网页(正确)]
[System.ComponentModel.Category(“父子属性”)]
[WebDisplayName(“父视图”)]
[WebDescription(“查看父列表”)]
公共字符串父视图
{
得到
{
如果(_ParentView==null)
{
_ParentView=“”;
}
返回_ParentView.Trim();
}
设置{u ParentView=value.Trim();}
}
[
可个性化(PersonalizationScope.Shared)]
[
可浏览网页(正确)]
[System.ComponentModel。
类别(“父子属性”)]
[
WebDisplayName(“ParentIDField”)]
[
WebDescription(“父列表中的ID字段”)]
公共字符串ParentIDField
{
得到
{
如果(_ParentIDField==null)
{
_ParentIDField=“”;
}
返回_ParentIDField.Trim();
}
设置{u ParentIDField=value.Trim();}
}
[可个性化(PersonalizationScope.Shared)]
[可浏览网页(正确)]
[System.ComponentModel。
类别(“父子属性”)]
[WebDisplayName(“FirstChildList”)]
[WebDescription(“FirstChildList名称”)]
公共字符串FirstChildList
{
得到
{
if(_FirstChildList==null)
{
_FirstChildList=“”;
}
return _FirstChildList.Trim();
}
设置{u FirstChildList=value.Trim();}
}
[可个性化(PersonalizationScope.Shared)]
[可浏览网页(正确)]
[System.ComponentModel.Category(“父子属性”)]
[WebDisplayName(“FirstChildView”)]
[WebDescription(“第一个子视图名称”)]
公共字符串FirstChildView
{
得到
{
如果(_FirstChildView==null)
{
_FirstChildView=“”;
}
return_FirstChildView.Trim();
}
设置{u FirstChildView=value.Trim();}
}
[可个性化(PersonalizationScope.Shared)]
[可浏览网页(正确)]
[System.ComponentModel.Category(“父子属性”)]
[WebDisplayName(“FirstChildIDField”)]
[WebDescription(“第一个孩子ID字段(类型ID)”)]
公共字符串FirstChildIDField
{
得到
{
如果(_FirstChildIDField==null)
{
_FirstChildIDField=“”;
}
返回_FirstChildIDField.Trim();
}
设置{u FirstChildIDField=value.Trim();}
}
[可个性化(PersonalizationScope.Shared)]
[可浏览网页(正确)]
[System.ComponentModel.Category(“父子属性”)]
[WebDisplayName(“FirstChildParentIDField”)]
[WebDescription(“第一个子父ID字段”)]
公共字符串FirstChildParentIDField
{
得到
{
if(_FirstChildParentIDField==null)
{
_FirstChildParentIDField=“”;
}
返回_FirstChildParentIDField.Trim();
}
设置{u FirstChildParentIDField=value.Trim();}
}
[可个性化(PersonalizationScope.Shared)]
[可浏览网页(正确)]
[System.ComponentModel。
类别(“父子属性”)]
[WebDisplayName(“SecondChildList”)]
[WebDescription(“第二个子列表”)]
公共字符串SecondChildList
{
得到
{
如果(_SecondChildList==null)
{
_SecondChildList=“”;
}
return_SecondChildList.Trim();
}
设置{u SecondChildList=value.Trim();}
}
[可个性化(PersonalizationScope.Shared)]
[可浏览网页(正确)]
[System.ComponentModel。
类别(“父子属性”)]
[WebDisplayName(“SecondChildView”)]
[
WebDescription(“第二个子视图”)]
公共字符串SecondChildView
{
得到
{
如果(_SecondChildView==null)
{
_SecondChildView=“”;
}
return_SecondChildView.Trim();
}
设置{u SecondChildView=value.Trim();}
}
[可个性化(PersonalizationScope.Shared)]
[可浏览网页(正确)]
[System.ComponentModel。
类别(“父子属性”)]
[WebDisplayName(“S