Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
131 views

ok,  I am getting the error

Missing operand before '=' operator.

when I try and export and the code is running fine in the grid.

Here is the code for the web part.  The error only occurs on the rebind.  It works fine in the grid itself.  Is there any way to narrow down the exact thing it is erroring on?

I am willing to pay for a support / solution to this problem, I just need it to work.

 

[

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><input class='ms-SPButton' value=\'Test Code\' type=button onclick=\"ByeBye();\" >"));

 

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 > 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 =

"<Where><Eq><FieldRef Name='" + cParentIDField + "' /><Value Type='Text'>" + cContractID + "</Value></Eq></Where>";

 

}

 

else

 

 

 

 

 

{

oChildQuery.Query =

"<Where><Eq><FieldRef Name='" + cParentIDField + "' /><Value Type='Text'>" + cContractID + "</Value></Eq></Where>";

 

}

 

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 > 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

 

 

 

 

 

{

}

 

}

 

 

}

Daniel
Telerik team
 answered on 17 Aug 2009
3 answers
316 views

When I try to upload a file, I always get as filename "Object reference not set to an instance of an object." and I couldn't find the problem.

that's my web.config :

    <system.web> 
        <httpRuntime maxRequestLength="1024000" executionTimeout"3600" /> 
        <compilation debug="true">  
            <assemblies> 
                <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>  
                <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
                <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>  
                <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>  
            </assemblies> 
        </compilation> 
        <authentication mode="Windows"/>  
        <pages> 
            <controls> 
                <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
                <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
            </controls> 
        </pages> 
        <httpHandlers> 
            <remove verb="*" path="*.asmx"/>  
            <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
            <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
            <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>  
            <add verb="*" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler, Telerik.Web.UI" validate="false" /> 
        </httpHandlers> 
        <httpModules> 
            <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
            <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" /> 
        </httpModules> 
    </system.web> 
    <system.codedom> 
        <compilers> 
            <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">  
                <providerOption name="CompilerVersion" value="v3.5"/>  
                <providerOption name="WarnAsError" value="false"/>  
            </compiler> 
            <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">  
                <providerOption name="CompilerVersion" value="v3.5"/>  
                <providerOption name="OptionInfer" value="true"/>  
                <providerOption name="WarnAsError" value="false"/>  
            </compiler> 
        </compilers> 
    </system.codedom> 
    <system.webServer> 
        <validation validateIntegratedModeConfiguration="false"/>  
        <modules> 
            <remove name="ScriptModule"/>  
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
            <add name="RadUploadModule" preCondition="integratedMode" type="Telerik.Web.UI.RadUploadHttpModule" /> 
        </modules> 
        <handlers> 
            <remove name="WebServiceHandlerFactory-Integrated"/>  
            <remove name="ScriptHandlerFactory"/>  
            <remove name="ScriptHandlerFactoryAppServices"/>  
            <remove name="ScriptResource"/>  
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
            <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
            <add name="Telerik.RadUploadProgressHandler.ashx_*" path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" preCondition="integratedMode,runtimeVersionv2.0" /> 
        </handlers> 
        <security > 
            <requestFiltering> 
                <requestLimits maxAllowedContentLength="1024000000" /> 
            </requestFiltering> 
        </security> 
    </system.webServer> 
    <runtime> 
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
            <dependentAssembly> 
                <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>  
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>  
            </dependentAssembly> 
            <dependentAssembly> 
                <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>  
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>  
            </dependentAssembly> 
        </assemblyBinding> 
    </runtime> 
Genady Sergeev
Telerik team
 answered on 17 Aug 2009
2 answers
90 views
Hello,

I have a RadGrid inside of a RadAjaxPanel which is inside of a asp:Content control using master pages. Very basic page with the grid getting populated from an EntityDataSource. I have AllowPaging enabled on the grid. When the grid first loads (it has 2 pages), if I try to click on Next Page or Last Page, nothing happens. If I actually click the numeric "2" it will take me to the second page. If I go back to the first page and try the Next Page or Last Page buttons, they suddenly begin working. Its as if I must go to another page first before the paging buttons work.

Any thoughts?

Code:
<telerik:RadAjaxPanel ID="Ajax" runat="server">
        <telerik:RadGrid ID="PageGrid" runat="server" EnableViewState="false" DataSourceID="PagesDS"
            GridLines="None" AllowSorting="true" AutoGenerateColumns="false" AllowPaging="true"
            AllowFilteringByColumn="true" PagerStyle-AlwaysVisible="true">
            <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true" />
            <MasterTableView DataSourceID="PagesDS" ClientDataKeyNames="ID" AllowNaturalSort="false">
                <Columns>
                    <telerik:GridBoundColumn DataField="Word" HeaderText="Word"
                        SortExpression="Word" UniqueName="Word" ItemStyle-Wrap="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Definition" HeaderText="Definition"
                        SortExpression="Definition" UniqueName="Definition">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>
    <br /><br />
    <asp:EntityDataSource ID="PagesDS" runat="server"
        ConnectionString="name=BeST_Entities" DefaultContainerName="Database"
        EntitySetName="Terms"
        Select="it.[ID], it.[Word], it.[Definition]">
    </asp:EntityDataSource>
Matt Russell
Top achievements
Rank 1
 answered on 17 Aug 2009
6 answers
239 views
I have to Listboxes populated by a database. The goal is to copy items from RadListBoxSource to RadListBoxTarget. RadListBoxSource should insert the record via Autopostback into the database. The database is a Oracle 10.
The problem is, that the records in RadListBoxTarget won't be inserted into the database. Deleting from db works fine.
What's wrong with the code? Anyone got an idea?

<telerik:RadScriptManager runat="server" ID="RadScriptManager1" /> 
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" /> 
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1">  
          
        <telerik:RadListBox ID="RadListBoxSource" runat="server" Width="400px" Height="200px" 
            SelectionMode="Multiple" AllowTransfer="true"   
            TransferToID="RadListBoxTarget" AutoPostBackOnTransfer="true" 
            AllowReorder="false" TransferMode="Copy"   
            DataSourceID="SqlDataSourceSource" DataKeyField="ID" 
            DataTextField="ID" DataValueField="ID">  
        </telerik:RadListBox> 
 
        <telerik:RadListBox ID="RadListBoxTarget" runat="server" Width="400px" Height="200px" 
            SelectionMode="Multiple" AllowDelete="True" DataKeyField="ID"   
            DataSourceID="SqlDataSourceTarget"   
            DataTextField="ID" DataValueField="ID" 
            AutoPostBackOnDelete="true" AutoPostBackOnReorder="true"   
            TransferToID="RadListBoxSource">  
        </telerik:RadListBox> 
          
        <asp:SqlDataSource ID="SqlDataSourceSource" runat="server" ConnectionString="<%$ ConnectionStrings:BayerAgrarTVConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:BayerAgrarTVConnectionString.ProviderName %>" 
        SelectCommand="SELECT ID, HEADLINE FROM AGRARTV2009_MOVIES WHERE (PUBLISH = 1) ORDER BY HEADLINE">  
        </asp:SqlDataSource> 
          
        <asp:SqlDataSource ID="SqlDataSourceTarget" runat="server" ConnectionString="<%$ ConnectionStrings:BayerAgrarTVConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:BayerAgrarTVConnectionString.ProviderName %>" 
        SelectCommand="SELECT AGRARTV2009_MOVIES_TSR_BOX.ID_MOVIE AS ID, AGRARTV2009_MOVIES.HEADLINE FROM AGRARTV2009_MOVIES_TSR_BOX, AGRARTV2009_MOVIES WHERE AGRARTV2009_MOVIES_TSR_BOX.ID_MOVIE = AGRARTV2009_MOVIES.ID ORDER BY AGRARTV2009_MOVIES.HEADLINE" 
        InsertCommand="INSERT INTO AGRARTV2009_MOVIES_TSR_BOX (ID_MOVIE) VALUES (&ID)" 
        DeleteCommand="DELETE FROM AGRARTV2009_MOVIES_TSR_BOX WHERE ID_MOVIE = &ID">  
        <DeleteParameters> 
            <asp:Parameter Name="ID" Type="Int32" /> 
        </DeleteParameters> 
        <InsertParameters> 
            <asp:ControlParameter Name="ID" Type="Int32" /> 
        </InsertParameters> 
    </asp:SqlDataSource> 
          
    </telerik:RadAjaxPanel> 
Genady Sergeev
Telerik team
 answered on 17 Aug 2009
4 answers
171 views
Hi,

if I add a <telerik:RadWindow ID="a" runat="server" /> to an user control that is used in a complex page then I get the following error when the page is loaded in a web browser:

"Script control 'a' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors(). Parameter name: scriptControl"

Unfortunately the page including this user control is too complex so I cannot easily provide a simple test case. I just thought I'd ask here if you had an idea what could cause this error and how to fix it.

Thanks
Matt Jones
Top achievements
Rank 1
 answered on 17 Aug 2009
9 answers
283 views
I am using a single grid with drag drop and wanted to know if it is possible to somehow indicate that a row is "un-dropable".  Basically, i am doing this in the code behind, but it would be nice to prevent it from the client side.  Also, is it possible to specify that a row cannot be dragged?  I have tried using the client side model from the examples, but if i cancel the event, then i cannot drag-drop on any other rows for a while.  It seems to "hang" before i can drag-drop again.
Ricardo Pinto
Top achievements
Rank 1
 answered on 17 Aug 2009
4 answers
207 views
Hi,

I have been trying to extend the Telerik RadGrid.
Right now my extended grids do nothing more than configure the grid and add a couple of columns, but in the future I might want to add more functionality.
But the grid doesn't show properly and doesn't function either if I use my extended grid. There is no GridClientSelectColumn, sorting doesn't work, the whole pager item is gone, when I try to resize I get this error message: "MS Jscript runtime error: 'this.HeaderRow.cells[...].ScrollWidth' is null or not an object.", the size of the columns isn't right and I'm missing the 'name' column (next to the GridClientSelectColumn it should also show columns for the guid, name, username, email and role) and when double clicking a row the corresponding javascript doesn't get the proper guid for that row anymore.
All of this did work when I just put a RadGrid in my aspx page and then configured everything on that grid.
I would upload a screenshot that clearly shows some of the problems if I knew how to do this.

This is what I did:
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using Telerik.Web.UI; 
using System.Web.UI.WebControls; 
using CMS.Process; 
using System.IO; 
using System.Drawing; 
 
namespace CMS.WebControls.Grid 
    public class BasicCmsGrid : Telerik.Web.UI.RadGrid 
    { 
        public BasicCmsGrid() : base() { } 
 
        protected override void OnLoad(EventArgs e) 
        { 
            base.OnLoad(e); 
 
            this.GridLines = GridLines.None; 
            this.AutoGenerateColumns = false
            this.AllowMultiRowSelection = true
            this.AllowFilteringByColumn = false
            this.AllowSorting = true
            this.AllowPaging = true
            this.PageSize = 7; 
            this.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric; 
            this.PagerStyle.AlwaysVisible = true
 
            this.MasterTableView.RowIndicatorColumn.HeaderStyle.Width = Unit.Pixel(5); 
            this.MasterTableView.ExpandCollapseColumn.HeaderStyle.Width = Unit.Pixel(15); 
            this.MasterTableView.AllowMultiColumnSorting = false
 
            GridClientSelectColumn selectColumn = new GridClientSelectColumn(); 
            this.MasterTableView.Columns.Add(selectColumn); 
            selectColumn.HeaderStyle.Width = Unit.Pixel(15); 
            selectColumn.UniqueName = "CheckBoxcolumn"
 
            this.ClientSettings.AllowColumnsReorder = true
            this.ClientSettings.ReorderColumnsOnClient = true
 
            this.ClientSettings.Resizing.AllowColumnResize = true
            this.ClientSettings.Resizing.EnableRealTimeResize = true
            this.ClientSettings.Resizing.ClipCellContentOnResize = true
            this.ClientSettings.Resizing.ResizeGridOnColumnResize = false
 
            this.ClientSettings.Scrolling.SaveScrollPosition = true
            this.ClientSettings.Scrolling.UseStaticHeaders = true
            this.ClientSettings.Scrolling.AllowScroll = true
 
            this.ClientSettings.Selecting.AllowRowSelect = true
 
            this.ClientSettings.ClientEvents.OnRowSelecting = "CancelNonInputSelect"
            this.ClientSettings.ClientEvents.OnRowDeselecting = "CancelNonInputSelect"
            this.Page.ClientScript.RegisterClientScriptInclude("BasicCmsGridScript", Path.Combine(ConfigMan.Settings.BaseHref, "js/GridScripts/BasicCmsGridScript.js")); 
 
            ((CMS.Util.Page)this.Page).RegisterCssStyle(".rgAdvPart{ display:none;}");//hiding the page size selection controls 
        } 
 
        public override GridTableView CreateTableView() 
        { 
            return new BasicCmsGridTableView(this); 
        } 
 
        public override GridTableView MasterTableView 
        { 
            get 
            { 
                return base.MasterTableView; 
            } 
        } 
    } 
 
    public class BasicCmsGridTableView : GridTableView 
    { 
        public BasicCmsGridTableView() : base() { } 
 
        public BasicCmsGridTableView(RadGrid owner) : base(owner) { } 
 
        public BasicCmsGridTableView(RadGrid owner, bool isTrackingViewState) : base(owner, isTrackingViewState) { } 
 
        protected override GridTableView CreateTableView(RadGrid owner, bool isTrackingViewState) 
        { 
            return new BasicCmsGridTableView(owner, isTrackingViewState); 
        } 
    } 
 
The CancelNonInputSelect JS function lets you (de)select a row only by (un)checking the checkbox in the GridClientSelectColumn and not by clicking anywhere else on a row. This still works properly.
If any contructor and such is redundant for my purposes please let me know. I have been looking around for more information and just tried anything I came across.

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using Telerik.Web.UI; 
using System.Web.UI.WebControls; 
using System.IO; 
using CMS.Process; 
 
namespace CMS.WebControls.Grid 
    public class CmsUsersGrid : BasicCmsGrid 
    { 
        public CmsUsersGrid() : base() { } 
 
        protected override void OnLoad(EventArgs e) 
        { 
            base.OnLoad(e); 
 
            this.MasterTableView.NoMasterRecordsText = "Geen gebruikers om te tonen."
 
            GridBoundColumn guidColumn = new GridBoundColumn(); 
            this.MasterTableView.Columns.Add(guidColumn); 
            guidColumn.DataField = "Guid"
            guidColumn.DataType = typeof(System.Guid); 
            guidColumn.UniqueName = "Guid"
            guidColumn.Visible = false
            guidColumn.ReadOnly = true
 
            GridBoundColumn nameColumn = new GridBoundColumn(); 
            this.MasterTableView.Columns.Add(nameColumn); 
            nameColumn.DataField = "Name"
            nameColumn.HeaderText = "Naam"
            nameColumn.SortExpression = "Name"
            nameColumn.UniqueName = "Name"
            nameColumn.HeaderStyle.Width = Unit.Pixel(105); 
 
            GridBoundColumn usernameColumn = new GridBoundColumn(); 
            this.MasterTableView.Columns.Add(usernameColumn); 
            usernameColumn.DataField = "Username"
            usernameColumn.HeaderText = "Gebruikersnaam"
            usernameColumn.SortExpression = "Username"
            usernameColumn.UniqueName = "Username"
            usernameColumn.HeaderStyle.Width = Unit.Pixel(105); 
 
            GridBoundColumn emailColumn = new GridBoundColumn(); 
            this.MasterTableView.Columns.Add(emailColumn); 
            emailColumn.DataField = "Email"
            emailColumn.HeaderText = "Emailadres"
            emailColumn.SortExpression = "Email"
            emailColumn.UniqueName = "Email"
            emailColumn.HeaderStyle.Width = Unit.Pixel(105); 
 
            GridBoundColumn roleColumn = new GridBoundColumn(); 
            this.MasterTableView.Columns.Add(roleColumn); 
            roleColumn.DataField = "Role"
            roleColumn.HeaderText = "Rol"
            roleColumn.SortExpression = "Role"
            roleColumn.UniqueName = "Role"
            roleColumn.HeaderStyle.Width = Unit.Pixel(105); 
 
            this.MasterTableView.ClientDataKeyNames = new String[] { "Guid" }; 
 
            this.ClientSettings.ClientEvents.OnRowDblClick = "RowDblClick"
            this.Page.ClientScript.RegisterClientScriptInclude("UsersGridAdditionalScript", Path.Combine(ConfigMan.Settings.BaseHref, "js/GridScripts/UsersGridAdditionalScript.js")); 
        } 
 
        public override GridTableView CreateTableView() 
        { 
            return new CmsUsersGridTableView(this); 
        } 
 
        public override GridTableView MasterTableView 
        { 
            get 
            { 
                return base.MasterTableView; 
            } 
        } 
    } 
 
    public class CmsUsersGridTableView : GridTableView 
    { 
        public CmsUsersGridTableView() : base() { } 
 
        public CmsUsersGridTableView(RadGrid owner) : base(owner) { } 
 
        public CmsUsersGridTableView(RadGrid owner, bool isTrackingViewState) : base(owner, isTrackingViewState) { } 
 
        protected override GridTableView CreateTableView(RadGrid owner, bool isTrackingViewState) 
        { 
            return new CmsUsersGridTableView(owner, isTrackingViewState); 
        } 
    } 
 
Some texts are in Dutch.
The RowDblClick JS sends you to the details page of the corresponding user, or at least it is supposed to.
Again there might be redundant constructors and methods here.

And this is where I try to use the CmsUsersGrid:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Gebruikers_List.aspx.cs" Inherits="CMS.Views.Beheer.Gebruikers.Gebruikers_List" %> 
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
<%@ Register Assembly="CMS" Namespace="CMS.WebControls.Grid" TagPrefix="CmsGrids" %> 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
 
<html> 
<head runat="server"
    <title>Gebruikers overzicht</title> 
    <link rel="stylesheet" type="text/css" href="../../../Layout/stylesheet.css" /> 
</head> 
 
<body> 
    <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
        <asp:UpdatePanel ID="upUsersList" runat="server"
        <ContentTemplate> 
            <CmsGrids:CmsUsersGrid ID="rgUsersGrid" runat="server" onneeddatasource="rgUsersGrid_NeedDataSource" /> 
        </ContentTemplate> 
        </asp:UpdatePanel> 
    </form> 
</body> 
</html> 
 

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
 
using CMS.Business; 
 
using Telerik.Web.UI; 
using System.Data; 
using CMS.Process; 
using CMS.Util; 
 
namespace CMS.Views.Beheer.Gebruikers 
    /// <summary> 
    ///     shows a list of all users 
    /// </summary> 
    public partial class Gebruikers_List : CMS.Util.Page 
    { 
        private IOrderedEnumerable<CMSUser> _users = null
 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            RetrieveObjects(); 
 
            if (!IsPostBack) 
            { 
                InitForm(); 
            } 
        } 
 
        private void RetrieveObjects() 
        { 
            //get all users, ordered by name 
            _users = CMSUser.RetrieveAll().ToList().OrderBy(u => u.ToString()); 
        } 
 
        private void InitForm() 
        { 
            //GridConfigor.ConfigAsUsersGrid(rgUsersGrid, this); 
        } 
 
        protected void rgUsersGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
        { 
            DataTable table = new DataTable("xxx"); 
            table.Columns.Add("Guid"); 
            table.Columns.Add("Name"); 
            table.Columns.Add("UserName"); 
            table.Columns.Add("Email"); 
            table.Columns.Add("Role"); 
            foreach (CMSUser user in _users) 
            { 
                table.Rows.Add(user.usr_GUID, user.ToString(), user.usr_username, user.usr_email, (UserRole)user.usr_role); 
            } 
 
            rgUsersGrid.DataSource = table; 
        } 
    } 
 

Please help me out with this one.

Regards,

Mink

Mink
Top achievements
Rank 1
 answered on 17 Aug 2009
1 answer
97 views
Hello,
I have a Sharepoint Site with a list which has 4 fields : name, Sirname, Department,Section. I want to have a grid which will have dynamic filtering on each of these fileds. So, when I type C in field name, the grid will show all the rows where names start witn C . If I type D in the Sirename fields, the grid will show all the rows where sirename starts with c and so on.
Dows Grid has these functionality?
If not, what will be the best approach using telerik products?
Also, If I don't want filtering but the grid to show rows greater that equal to the letters i type (same functionality that outlook has in address book.
Thank you
Mr. Plinko
Top achievements
Rank 1
 answered on 17 Aug 2009
1 answer
85 views
I'm adding values to a custom DropDownList on the server w/ the following format:

<img fieldName=\"{0}\" tableName=\"{1}\" alt=\"[{2}]\" style=\"font-weight: bold\" />

When the user selects one of the values in the DropDownList, the OnClientCommandExecuting pastes the value of the selectedItem
as follows:



function templateEditorOnClientCommandExecuting(sender, eventArgs) 
            { 
                var name = eventArgs.get_name(); 
                var val = eventArgs.get_value(); 
                                 
                if(name == "Fields"
                { 
                    if(val != null && val != ''
                    { 
                        sender.pasteHtml(val); 
                    } 
                    else 
                    { 
                        alert('Select a Template Type first'); 
                    } 
                     
                    eventArgs.set_cancel(true); 
                } 
            }      

The pasted value is as follows:

<img style=\"font-weight: bold;\" alt=\"[Address]\" tablename=\"Organization\" fieldname=\"MailAddress1\" />

Why is the order of the attributes of my img element on the client different than what I explicitly set on the server?  I'm trying to write a regular expression to do a replace of the img tag when the form is submitted, but I'm not able to due to the issue described above.


Rumen
Telerik team
 answered on 17 Aug 2009
2 answers
249 views
I have some JS functions that retrieve a latitude and longitude and set a couple radtextboxes to the value. The only problem is, they don't set these textboxes to the value until after you mouse into them. What happens is the user fills in address information. I then take that and parse it with google's gmap api to get a lat and lon. I set the textboxes value to those but it won't show up until you mouse into them. I need it to show as soon as it finds it. Here is my code
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/admin/Admin.Master"
    CodeBehind="AddBusiness.aspx.vb" Inherits="ClickableCommunity.AddBusiness" %>

<%@ Register Assembly="RadMenu" Namespace="Telerik.WebControls" TagPrefix="radM" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <telerik:RadScriptBlock ID="ScriptBlock1" runat="server">
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAANvmC5YwARPSDAHoiTGyjXRR-496V5WiR7LkdzcFVQzFkDe07hhSkvWarTS8udi3TGEWMPQwT-FAGew"
        type="text/javascript"></script>
        <script type="text/javascript">
            function getLatLon(sender, args) {

                var street = $find('<%= streetInput.ClientID %>').get_value();
                var city = $find('<%= cityInput.ClientID %>').get_value();
                var state = $find('<%= stateInput.ClientID %>').get_value();
                var zip = $find('<%= zipInput.ClientID %>').get_value();
                var address = (street + " " + city + ", " + state + " " + zip);

                geocodeAddress(address);
            } //getLatLon

            //this function takes in an address and returns
            //the lattitude and longitude.
            function geocodeAddress(address) {
                var coder = new GClientGeocoder();
                coder.getLatLng(address,
                  function(point) {
                      if (!point) {
                          alert(address + " not found");
                      } //if

                      //we set the textboxes to their values
                      else {
                          //this is where it sets the rad textboxes values
                          //to set instantly but they only set when you mouse in
                          var templat = $get('<%= latInput.ClientID %>');
                          var templon = $get('<%= lonInput.ClientID %>');
                          templat.value = point.lat();
                          templon.value = point.lng();
                          
                      } //else
                  } //function(point)
                );
            }//geocodeAddress           
        </script>

    </telerik:RadScriptBlock>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="header" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <table cellpadding="30" width="350px">
        <tr>
            <td>
                <span class="addBusinessLabel">Business Name</span>
                <telerik:RadTextBox ID="businessNameInput" runat="server" Skin="Web20" Width="150px">
                </telerik:RadTextBox>
            </td>
            <td>
                <span class="addBusinessLabel">User</span>
                <telerik:RadComboBox ID="RadComboBox2" runat="server" Skin="Web20" Width="150px">
                </telerik:RadComboBox>
            </td>
        </tr>
        <tr>
            <td>
                <span class="addBusinessLabel">Street Address</span>
                <telerik:RadTextBox ID="streetInput" runat="server" Skin="Web20" Width="150px">
                </telerik:RadTextBox>
            </td>
            <td>
                <span class="addBusinessLabel">City</span>
                <telerik:RadTextBox ID="cityInput" runat="server" Skin="Web20" Width="150px">
                </telerik:RadTextBox>
            </td>
        </tr>
        <tr>
            <td>
                <center>
                    <span class="addBusinessLabel">State</span>
                    <telerik:RadComboBox ID="stateInput" runat="server" Skin="Web20" Width="150px" ChangeTextOnKeyBoardNavigation="true"
                        MarkFirstMatch="true" DropDownWidth="150px">
                        <Items>
                            <telerik:RadComboBoxItem Text="Alabama" Value="AL" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Alaska" Value="AK" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Arizona" Value="AZ" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Arkansas" Value="AR" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="California" Value="CA" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Colorado" Value="CO" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Connecticut" Value="CT" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Delaware" Value="DE" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="District Of Columbia" Value="DC" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Florida" Value="FL" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Georgia" Value="GA" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Hawaii" Value="HI" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Idaho" Value="ID" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Illinois" Value="IL" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Indiana" Value="IN" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Iowa" Value="IA" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Kansas" Value="KS" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Kentucky" Value="KY" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Louisiana" Value="LA" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Maine" Value="ME" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Maryland" Value="MD" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Massachusetts" Value="MA" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Michigan" Value="MI" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Minnesota" Value="MN" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Mississippi" Value="MS" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Missouri" Value="MO" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Montana" Value="MT" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Nebraska" Value="NE" CssClass="stateDropDownText" Selected="true" />
                            <telerik:RadComboBoxItem Text="Nevada" Value="NV" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="New Hampshire" Value="NH" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="New Jersey" Value="NJ" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="New Mexico" Value="NM" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="New York" Value="NY" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="North Carolina" Value="NC" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="North Dakota" Value="ND" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Ohio" Value="OH" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Oklahoma" Value="OK" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Oregon" Value="OR" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Pennsylvania" Value="PA" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Rhode Island" Value="RI" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="South Carolina" Value="SC" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="South Dakota" Value="SD" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Tennessee" Value="TN" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Texas" Value="TX" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Utah" Value="UT" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Vermont" Value="VT" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Virginia" Value="VA" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Washington" Value="WA" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="West Virginia" Value="WV" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Wisconsin" Value="WI" CssClass="stateDropDownText" />
                            <telerik:RadComboBoxItem Text="Wyoming" Value="WY" CssClass="stateDropDownText" />
                        </Items>
                    </telerik:RadComboBox>
                </center>
            </td>
            <td>
                <span class="addBusinessLabel">Zip</span> <span style="width: 150px">
                    <telerik:RadTextBox ID="zipInput" runat="server" Skin="Web20" Width="150px">
                        <ClientEvents OnBlur="getLatLon" />
                    </telerik:RadTextBox>
                </span>
            </td>
        </tr>
        <tr>
            <td>
                <span class="addBusinessLabel">Latitude</span>
                <telerik:RadTextBox ID="latInput" runat="server" Skin="Web20" Width="150px">
                </telerik:RadTextBox>
            </td>
            <td>
                <span class="addBusinessLabel">Longitude</span>
                <telerik:RadTextBox ID="lonInput" runat="server" Skin="Web20" Width="150px">
                </telerik:RadTextBox>
            </td>
        </tr>
    </table>
</asp:Content>
Thanks,
Web Services
Top achievements
Rank 2
 answered on 17 Aug 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?