Telerik Forums
UI for ASP.NET AJAX Forum
10 answers
374 views
I have a databond radgrid and a databond detailtable within the radgrid. In the detailtable I have an extra checkbox column which is not databound.

When I click on a commandButton on a mastertable row I want to find the checkbox control within the detailtable of that mastertable row, and store the checkbox "Checked" value of each detailtable row somewhere else.

I use the following code to locate the detail table

if (e.CommandName == "TestCommand"
{
GridTableView gtv = (GridTableView)e.Item.OwnerTableView;
GridTableView gtvContents = (GridTableView)gtv.DetailTables[0];

When I was trying to loop through the detailtable to find the checkbox i realised that the row count is 0, which is incorrect, therefore i will not be able to find the checkbox control....

please help, thanks in advance
Saravanan Kannan
Top achievements
Rank 1
 answered on 17 Aug 2009
1 answer
104 views
Hi,
Currently I have 2 RadGrid (not using Ajax)
When I change the page index of RadGrid2, so that page postback and scroll to the top
How do I change the page index of RadGrid2, Scrollbar scroll to the header of RadGrid2
Sorry my bad English
Thanks
Mr. Plinko
Top achievements
Rank 1
 answered on 17 Aug 2009
2 answers
94 views
Hi,

I've followed the instructions on http://demos.telerik.com/aspnet-ajax/editor/examples/externaldialogspath/defaultcs.aspx and on http://www.telerik.com/community/forums/aspnet-ajax/editor/adding-functionality-to-a-customized-built-in-dialog.aspx in order to customise the hyperlink manager in the radeditor. This all works well except after the site has been compiled. After compilation and release the file LinkManager.ascx does not exist in the location specified in the property ExternalDialogsPath because it has been compiled into the bin folder. The compiled file name has also been changed so is not LinkManager.ascx, it is something like linkmanager.ascx.ab9a7aa3.compiled.

Is there a way around this that anyone knows?

Many thanks in advance,

Steve.
steve curtis
Top achievements
Rank 1
 answered on 17 Aug 2009
0 answers
90 views
<deleted>
Matthias S
Top achievements
Rank 1
 asked on 17 Aug 2009
3 answers
305 views

Hi, I’m upload and set image successfully to RadBinaryImage (image show correctly), but when try to access to DataValue property for save in database, the DataValue property is null. I need access to property, from click event of button named "btnSave", after image is uploaded.

Any Ideas.

Thanks for help!

Eloy.

Greg
Top achievements
Rank 1
 answered on 17 Aug 2009
1 answer
135 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
328 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
99 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
248 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
178 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
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?