error. Lets submit my code of aspx and aspx.cs page
<
telerik:RadGrid
ID
=
"rdgPermissionList"
runat
=
"server"
AllowFilteringByColumn
=
"false"
AllowPaging
=
"false"
BackColor
=
"White"
AllowSorting
=
"True"
GridLines
=
"Both"
AutoGenerateColumns
=
"false"
Skin
=
"MyCustomSkin"
EnableEmbeddedSkins
=
"false"
ShowGroupPanel
=
"false"
AllowMultiRowSelection
=
"true"
OnColumnCreated
=
"rdgPermissionList_ColumnCreated"
OnNeedDataSource
=
"rdgPermissionList_NeedDataSource"
OnItemDataBound
=
"rdgPermissionList_ItemDataBound"
OnItemCreated
=
"rdgPermissionList_ItemCreated"
OnItemCommand
=
"rdgPermissionList_ItemCommand"
Width
=
"99.5%"
EnableLinqExpressions
=
"false"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
PrevPageToolTip
=
"Previous"
NextPagesToolTip
=
"Next"
AlwaysVisible
=
"true"
/>
<
MasterTableView
CommandItemDisplay
=
"TopAndBottom"
DataKeyNames
=
"intFieldPermissionID,intModuleID,intModuleParentID,strRefLabel"
ItemStyle-HorizontalAlign
=
"Left"
AlternatingItemStyle-HorizontalAlign
=
"Left"
HierarchyDefaultExpanded
=
"false"
HierarchyLoadMode
=
"Client"
AllowSorting
=
"true"
EnableNoRecordsTemplate
=
"false"
AllowPaging
=
"true"
Name
=
"Master"
Width
=
"100%"
>
<
FilterItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemStyle
HorizontalAlign
=
"Left"
></
ItemStyle
>
<
AlternatingItemStyle
HorizontalAlign
=
"Left"
></
AlternatingItemStyle
>
<
SelfHierarchySettings
ParentKeyName
=
""
KeyName
=
"intModuleID"
/>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"strRefLabel"
HeaderText
=
"Modules"
SortExpression
=
"strRefLabel"
UniqueName
=
"strRefLabel"
HeaderStyle-Width
=
"60px"
ItemStyle-HorizontalAlign
=
"Left"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Enable"
HeaderStyle-Width
=
"40px"
UniqueName
=
"Enable"
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"chkEnable"
runat
=
"server"
Checked='<%# Eval("ysnEnable").ToString().ToLower()=="1"?true:false %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
RowIndicatorColumn
Visible
=
"True"
>
</
RowIndicatorColumn
>
<
CommandItemTemplate
>
<
table
width
=
"100%"
>
<
tr
>
<
td
id
=
"tdSave"
runat
=
"server"
style
=
"width: 4%"
align
=
"left"
valign
=
"top"
>
<
asp:ImageButton
ImageUrl
=
"~/images/tick.gif"
ID
=
"btnSave"
runat
=
"server"
CommandName
=
"Update"
>
</
asp:ImageButton
>
</
td
>
<
td
style
=
"width: 96%"
align
=
"left"
>
<
asp:ImageButton
ImageUrl
=
"~/images/Cancel.gif"
ID
=
"btnCancel"
CausesValidation
=
"False"
runat
=
"server"
CommandName
=
"Cancel"
></
asp:ImageButton
>
</
td
>
</
tr
>
</
table
>
</
CommandItemTemplate
>
</
MasterTableView
>
<
HeaderStyle
Width
=
"50px"
Height
=
"25px"
/>
<
ClientSettings
AllowColumnsReorder
=
"True"
AllowKeyboardNavigation
=
"true"
AllowAutoScrollOnDragDrop
=
"true"
EnableRowHoverStyle
=
"true"
ReorderColumnsOnClient
=
"true"
AllowDragToGroup
=
"True"
AllowExpandCollapse
=
"true"
>
<
ClientMessages
DragToGroupOrReorder
=
"Select All"
/>
<
Resizing
AllowColumnResize
=
"true"
EnableRealTimeResize
=
"true"
/>
</
ClientSettings
>
<
FilterMenu
EnableEmbeddedSkins
=
"false"
>
</
FilterMenu
>
</
telerik:RadGrid
>
using System;
using System.Linq;
using System.Data;
using System.Reflection;
using System.Web.UI;
using System.Web.UI.WebControls;
using A1_A1Tracker_CNetWeb.Components.DataAccess;
using A1_A1Tracker_CNetWeb.Components.Security;
using Telerik.Web.UI;
namespace A1_A1Tracker_CNetWeb.Modules.System
{
public partial class FieldPermissionDetails : A1_A1Tracker_CNetWeb.Components.Web.UI.Page
{
UserPermission UserPerms;
int groupId = 0;
protected void Page_Init(object sender, EventArgs e)
{
UserPerms = new UserPermission();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (!(UserPerms.CheckPerms(A1_A1Tracker_CNetWeb.Components.Security.Module.Security, PermissionLevel.ReadOnly)))
Response.Redirect("~/Modules/UserAuthentication/ErrorPage.aspx?NoPerms=true");
}
groupId = Convert.ToInt32(Request.QueryString["groupId"]);
if (Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("4.0") != -1)
{
rdgPermissionList.MasterTableView.FilterExpression = @"it[""intModuleParentID""] = Convert.DBNull";
}
else
{
rdgPermissionList.MasterTableView.FilterExpression = "intModuleParentID IS NULL";
}
RadDockPermissionDetail.Title = "<
a
href
=
'Permission.aspx'
style
=
'color:black; cursor:hand; text-decoration:none;'
> Permission </
a
> >> " + "Field Permission Details for " + Convert.ToString(Request.QueryString["groupname"]);
}
protected void rdgPermissionList_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
DataAccessHelper objDataAccess = new DataAccessHelper();
DataTable dtPermissionList = objDataAccess.GetFieldPermission(groupId);
objDataAccess = null;
if (dtPermissionList.Rows.Count != 0)
{
//if (rdgPermissionList.MasterTableView.FilterExpression.Length > 0)
//{
// var newTable = dtPermissionList.AsEnumerable().AsQueryable().Where(@"it[""intModuleParentID""] = Convert.DBNull").CopyToDataTable();
//}
//if (rdgPermissionList.MasterTableView.FilterExpression.Length > 0)
//{
// var tempTable = dtPermissionList.AsEnumerable().AsQueryable().Where(rdgPermissionList.MasterTableView.FilterExpression);
// if (tempTable.Count() > 0)
// {
// dsCopy.Load(tempTable.CopyToDataTable().CreateDataReader(),
// LoadOption.OverwriteChanges, strTables);
// }
//}
rdgPermissionList.DataSource = dtPermissionList.DefaultView;
}
}
protected void rdgPermissionList_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.UpdateCommandName)
{
string fieldsXML = "<
root
>";
foreach (GridDataItem item in rdgPermissionList.Items)
{
string test = item.OwnerTableView.Name;
String moduleId = item.GetDataKeyValue("intModuleID").ToString();
String permissionId = item.GetDataKeyValue("intFieldPermissionID").ToString();
CheckBox enable = item["Enable"].FindControl("chkEnable") as CheckBox;
fieldsXML += "<
FIELDS
>";
fieldsXML += "<
ModuleId
>" + moduleId + "</
ModuleId
>" + "\n";
fieldsXML += "<
FieldPermissionID
>" + permissionId + "</
FieldPermissionID
>" + "\n";
fieldsXML += "<
Enable
>" + enable.Checked + "</
Enable
>" + "\n";
fieldsXML += "</
FIELDS
>";
}
fieldsXML += "</
root
>";
DataAccessHelper objDataAccess = new DataAccessHelper();
objDataAccess.SaveFieldPermission(groupId, fieldsXML);
objDataAccess = null;
this.lblMsg.Text = "Field Permission updated successfully.";
}
else if (e.CommandName == RadGrid.CancelCommandName)
{
Response.Redirect("Permission.aspx");
}
}
protected void rdgPermissionList_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
GridBoundColumn boundColumn = e.Column as GridBoundColumn;
switch (e.Column.UniqueName)
{
case "strRefLabel":
break;
case "ysnEnable":
break;
default:
e.Column.Visible = false;
break;
}
}
protected void rdgPermissionList_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridCommandItem)
{
//Apply Permission for Add and Delete
GridCommandItem commandItem = e.Item as GridCommandItem;
if (!(UserPerms.CheckPerms(A1_A1Tracker_CNetWeb.Components.Security.Module.Security, PermissionLevel.Add, PermissionLevel.Edit, PermissionLevel.Delete)))
(commandItem.FindControl("btnSave") as ImageButton).Parent.Visible = false;
}
CreateExpandCollapseButton(e.Item, "strRefLabel");
if ((e.Item is GridHeaderItem || e.Item is GridCommandItem || e.Item is GridPagerItem) && e.Item.OwnerTableView != rdgPermissionList.MasterTableView)
{
e.Item.Style["display"] = "none";
}
if (e.Item is GridNestedViewItem)
{
e.Item.Cells[0].Visible = false;
}
}
protected void Page_PreRender(object sender, EventArgs e)
{
HideExpandColumnRecursive(rdgPermissionList.MasterTableView);
}
public void HideExpandColumnRecursive(GridTableView tableView)
{
GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
{
foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
{
nestedView.Style["border"] = "0";
Button MyExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton");
if (nestedView.Items.Count == 0)
{
if (MyExpandCollapseButton != null)
{
MyExpandCollapseButton.Style["visibility"] = "hidden";
}
nestedViewItem.Visible = false;
}
else
{
if (MyExpandCollapseButton != null)
{
MyExpandCollapseButton.Style.Remove("visibility");
}
}
if (nestedView.HasDetailTables)
{
HideExpandColumnRecursive(nestedView);
}
}
}
}
protected void rdgPermissionList_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
string parentId = item.GetDataKeyValue("intModuleParentID").ToString();
if (string.IsNullOrEmpty(parentId))
{
if (item.OwnerTableView.HasDetailTables)
{
CheckBox chkReadOnly = (CheckBox)item["Enable"].Controls[1];
if (chkReadOnly != null)
chkReadOnly.Attributes.Add("onclick", "MasterCheckBoxClick(this,'" + item.ItemIndex + "','chkEnable');");
}
}
}
CreateExpandCollapseButton(e.Item, "strRefLabel");
}
public void CreateExpandCollapseButton(GridItem item, string columnUniqueName)
{
if (item is GridDataItem)
{
if (item.FindControl("MyExpandCollapseButton") == null)
{
Button button = new Button();
button.Click += new EventHandler(button_Click);
button.CommandName = "ExpandCollapse";
button.CssClass = (item.Expanded) ? "rgCollapse" : "rgExpand";
button.ID = "MyExpandCollapseButton";
if (item.OwnerTableView.HierarchyLoadMode == GridChildLoadMode.Client)
{
string script = String.Format(@"$find(""{0}"")._toggleExpand(this, event); return false;", item.Parent.Parent.ClientID);
button.OnClientClick = script;
}
int level = item.ItemIndexHierarchical.Split(':').Length;
if (level > 1)
{
button.Style["margin-left"] = level + 9 + "px";
}
TableCell cell = ((GridDataItem)item)[columnUniqueName];
cell.Controls.Add(button);
cell.Controls.Add(new LiteralControl(" "));
cell.Controls.Add(new LiteralControl(((GridDataItem)item).GetDataKeyValue(columnUniqueName).ToString()));
}
}
}
void button_Click(object sender, EventArgs e)
{
((Button)sender).CssClass = (((Button)sender).CssClass == "rgExpand") ? "rgCollapse" : "rgExpand";
}
}
}