Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Dynamically column add problem
posted

 Hi all 

I'm been looking around for an answer to this but looks like i can't find any

I'm using Infragistics 17.1 WebDataGrid i added dynamically checkbox column and paging  function 

as you can see in the attached code

The problem is that when click the Paging button after changing the checkbox value, the following error occurs: 

Thanks in advance for any help.

code 

BoundCheckBoxField CKfield = new BoundCheckBoxField();
CKfield.Key = ColumnName;
CKfield.Header.Text = HeaderCaption;
CKfield.DataFieldName = ColumnName;
CKfield.Width = Width;
#region Column HeaderAlign
if (HeaderAlign == HorizontalAlign.Center)
{
CKfield.Header.CssClass = "HCAlign";
}
if (HeaderAlign == HorizontalAlign.Justify)
{
CKfield.Header.CssClass = "HJAlign";
}
if (HeaderAlign == HorizontalAlign.Left)
{
CKfield.Header.CssClass = "HLAlign";
}
if (HeaderAlign == HorizontalAlign.NotSet)
{
CKfield.Header.CssClass = "HLAlign";
}
if (HeaderAlign == HorizontalAlign.Right)
{
CKfield.Header.CssClass = "HRAlign";
}
#endregion

#region Column ContentAlign
if (ColumnAlign == HorizontalAlign.Center)
{
CKfield.CssClass = "CAlign";
}
if (ColumnAlign == HorizontalAlign.Justify)
{
CKfield.CssClass = "JAlign";
}
if (ColumnAlign == HorizontalAlign.Left)
{
CKfield.CssClass = "LAlign";
}
if (ColumnAlign == HorizontalAlign.NotSet)
{
CKfield.CssClass = "LAlign";
}
if (ColumnAlign == HorizontalAlign.Right)
{
CKfield.CssClass = "rAlign";
}
#endregion

if (Hidden)
CKfield.Hidden = true;
else
CKfield.Hidden = false;

EditingColumnSetting set = new EditingColumnSetting();
set.ColumnKey = ColumnName;
if (CheckUpdate == AllowUpdate.Yes)
{
set.ReadOnly = false;
}
else
{
set.ReadOnly = true;
}
base.Behaviors.CreateBehavior<EditingCore>();
base.Behaviors.EditingCore.Behaviors.CreateBehavior<CellEditing>();
base.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(set);

base.Columns.Add(CKfield);

error : 

[NotSupportedException]: A row can only be updated or deleted if the DataKeyFields property is set. 
위치: Infragistics.Web.UI.GridControls.EditingCore.OnAction(String actionType, Object id, Object value, Object tag) 
위치: Infragistics.Web.UI.GridControls.GridBehavior.Infragistics.Web.UI.GridControls.IGridBehavior.OnAction(String actionType, Object id, Object value, Object tag) 
위치: Infragistics.Web.UI.GridControls.GridBot.LoadAdditionalClientState(Object state) 
위치: Infragistics.Web.UI.Framework.RunBot.HandleRaisePostDataChangedEvent() 
위치: Infragistics.Web.UI.GridControls.GridBot.HandleRaisePostDataChangedEvent() 
위치: Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.RaisePostDataChangedEvent() 
위치: System.Web.UI.Page.RaiseChangedEvents() 
위치: System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
[HttpUnhandledException]: &#39;System.Web.HttpUnhandledException&#39; 형식의 예외가 Throw되었습니다. 
위치: System.Web.UI.Page.HandleError(Exception e) 
위치: System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
위치: System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
위치: System.Web.UI.Page.ProcessRequest() 
위치: System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) 
위치: System.Web.UI.Page.ProcessRequest(HttpContext context) 
위치: ASP.default2_aspx.ProcessRequest(HttpContext context) 파일 c:\Users\YoonPC\AppData\Local\Temp\Temporary ASP.NET Files\vs\0872ed3f\1efd606c\App_Web_edxwoipc.0.cs:줄 0 
위치: System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
위치: System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)