I've seen numerous other threads in which the update command is not working, but none of them I have found are exactly like my situation. I am programmatically building multiple RadGrids on a single page, each of which is contained in its own RadPanel, and all of the panels are inside a RadAjaxPanel. I am using a custom implementation of the IBindableTemplate for the RadGrid's EditForm. Everything is working fine when I click the delete button (Delete command is fired and the record is deleted).
When I click the "Add New Record" button, the template appears just fine, I can enter information, press the insert button, and the record is inserted and can be seen in the grid. However, when I click on the edit button, the grid goes into edit mode just fine, all values are populated in the template just as they should be and an "Edit" item command is fired.
However, once inside this edit mode, no events fire. If I click on the update button, no update command is fired, and the same is true for the cancel button. I don't understand why the edit mode fails to work but the insert mode works just fine. Any help would be appreciated!
When I click the "Add New Record" button, the template appears just fine, I can enter information, press the insert button, and the record is inserted and can be seen in the grid. However, when I click on the edit button, the grid goes into edit mode just fine, all values are populated in the template just as they should be and an "Edit" item command is fired.
However, once inside this edit mode, no events fire. If I click on the update button, no update command is fired, and the same is true for the cancel button. I don't understand why the edit mode fails to work but the insert mode works just fine. Any help would be appreciated!
6 Answers, 1 is accepted
0
Hi Andrew,
From your description it is not clear what may be the cause for the problem in your application. I can suggest you yo review the following help article which explains how a custom edit form can be created programmaticaly:
http://www.telerik.com/help/aspnet-ajax/grid-custom-edit-forms.html
Please review it and if you still cannot determine what may be wrong, provide some relevant code so we can get a better idea of your scenario.
All the best,
Pavel
the Telerik team
From your description it is not clear what may be the cause for the problem in your application. I can suggest you yo review the following help article which explains how a custom edit form can be created programmaticaly:
http://www.telerik.com/help/aspnet-ajax/grid-custom-edit-forms.html
Please review it and if you still cannot determine what may be wrong, provide some relevant code so we can get a better idea of your scenario.
All the best,
Pavel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Andrew
Top achievements
Rank 1
answered on 22 Jun 2011, 04:13 PM
That is actually the help article that I used to create my RadGrids.Unfortunately I am still having the same issue. The insert commands work fine (InitInsert, PerformInsert, Cancel), the delete command works fine, and upon clicking the edit button the 'Edit' command fires just fine, but once inside the template the 'Update' and 'Cancel' commands do not work and no command is fired. Below is the code to my .aspx page:
Below is the relevant code that builds the page:
Again, any help would be wonderful! Thanks!
<%@ Page Title="" Language="C#" MasterPageFile="~/Web/Users/User.Master" AutoEventWireup="true" CodeBehind="CRUDEntries.aspx.cs" Inherits="BattelleMSR.Web.Users.UsersCRUDEntries" %>
<%@ Register Src="~/Controls/DeliverablesEntryType.ascx" TagName="Deliverables" TagPrefix="EntryTypes" %>
<%@ Register Src="~/Controls/SignificantActionsEntryType.ascx" TagName="SignificantActions"
TagPrefix="EntryTypes" %>
<%@ Register Src="~/Controls/TrainingEntryType.ascx" TagName="Training" TagPrefix="EntryTypes" %>
<%@ Register Src="~/Controls/UpcomingActionsEntryType.ascx" TagName="UpcomingActions"
TagPrefix="EntryTypes" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
asp:Content
ID
=
"Content4"
ContentPlaceHolderID
=
"PageName"
runat
=
"server"
>
User - Add/Edit/Delete Monthy Entries
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"Main"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function StandardConfirm(sender, args)
{
args.set_cancel(!window.confirm("Are you sure you want to complete the entries for this project? \nEntries can no longer be added/edited!"));
}
</
script
>
<
br
/>
<
div
class
=
"accordian_container"
>
<
asp:Label
ID
=
"Message"
runat
=
"server"
CssClass
=
"WarningText"
/>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
>
<
telerik:RadPanelBar
runat
=
"server"
ID
=
"RadPanelBar1"
ExpandMode
=
"SingleExpandedItem"
Width
=
"900px"
Skin
=
"Default"
>
</
telerik:RadPanelBar
>
</
telerik:RadAjaxPanel
>
</
div
>
<
br
/>
<
center
>
<
telerik:RadButton
ID
=
"btnStandardConfirm"
runat
=
"server"
Text
=
"Complete"
OnClientClicking
=
"StandardConfirm"
OnClick
=
"Button_Click"
/>
<
br
/>
<
asp:Label
ID
=
"errorMessage"
runat
=
"server"
Visible
=
"false"
ForeColor
=
"Red"
></
asp:Label
>
</
center
>
</
asp:Content
>
Below is the relevant code that builds the page:
public
partial
class
UsersCRUDEntries : UserBasePage
{
EntryType currentType =
null
;
private
void
BuildEntryTypeTemplate(Control container)
{
//This is where we need to build the RadGrid for the current entry type
//First, create the outer div that will hold all contents
HtmlGenericControl outerDiv =
new
HtmlGenericControl();
outerDiv.Style.Add(
"width"
,
"850px"
);
outerDiv.Style.Add(
"margin-left"
,
"auto"
);
outerDiv.Style.Add(
"margin-right"
,
"auto"
);
//Create the text holder that will hold an error message for forbidden words,
//if the user enters one
Label textHolder =
new
Label();
textHolder.ID =
"textHolder_"
+ currentType.Id.ToString();
textHolder.Visible =
false
;
textHolder.ForeColor = Color.Red;
textHolder.Style.Add(
"align"
,
"center"
);
//Add the label to the outer div
outerDiv.Controls.Add(textHolder);
//Add a break statement after the label so there's a space between it and the grid
outerDiv.Controls.Add(
new
HtmlGenericControl(
"br"
));
//Now we need to create the actual grid that will display the actual entries of each
//entry type
RadGrid entryTypeGrid =
new
RadGrid();
entryTypeGrid.ID =
"entryTypeGrid_"
+ currentType.Id.ToString();
entryTypeGrid.AllowPaging =
true
;
entryTypeGrid.Width =
new
Unit(
"850px"
);
entryTypeGrid.Height =
new
Unit(
"355px"
);
entryTypeGrid.AutoGenerateColumns =
false
;
entryTypeGrid.AllowAutomaticUpdates =
true
;
entryTypeGrid.PageSize = 10;
entryTypeGrid.CommandItemStyle.Wrap =
true
;
entryTypeGrid.EnableHeaderContextMenu =
true
;
entryTypeGrid.RowDrop +=
new
GridDragDropEventHandler(EntryTypeGrid_RowDrop);
entryTypeGrid.InsertCommand +=
new
GridCommandEventHandler(EntryTypeGrid_InsertCommand);
entryTypeGrid.UpdateCommand +=
new
GridCommandEventHandler(EntryTypeGrid_UpdateCommand);
entryTypeGrid.DeleteCommand +=
new
GridCommandEventHandler(EntryTypeGrid_DeleteCommand);
entryTypeGrid.ItemCommand +=
new
GridCommandEventHandler(entryTypeGrid_ItemCommand);
entryTypeGrid.ShowStatusBar =
true
;
//entryTypeGrid.NeedDataSource += new GridNeedDataSourceEventHandler(EntryTypeGrid_NeedDataSource);
entryTypeGrid.EnableViewState =
false
;
entryTypeGrid.Skin =
"Windows7"
;
//RadGrid >> Master Table View
entryTypeGrid.MasterTableView.DataKeyNames =
new
string
[] {
"id"
,
"action_word_id"
,
"entry"
};
entryTypeGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.TopAndBottom;
//RadGrid >> Master Table View >> Command Item Settings
entryTypeGrid.MasterTableView.CommandItemSettings.ExportToPdfText =
"Export to PDF"
;
//RadGrid >> Master Table View >> Row Indicator Column
entryTypeGrid.MasterTableView.RowIndicatorColumn.FilterControlAltText =
"Filter RowIndicator column"
;
entryTypeGrid.MasterTableView.ExpandCollapseColumn.FilterControlAltText =
"Filter ExpandColumn column"
;
//RadGrid >> Master Table View >> Columns
//Create and add the column used for drag and drop functionality
GridDragDropColumn dragDropColumn =
new
GridDragDropColumn();
dragDropColumn.HeaderStyle.Width =
new
Unit(
"18px"
);
dragDropColumn.Visible =
true
;
entryTypeGrid.MasterTableView.Columns.Add(dragDropColumn);
//Create and add the column that contains the action word
GridBoundColumn actionWordColumn =
new
GridBoundColumn();
actionWordColumn.DataField =
"value"
;
actionWordColumn.FilterControlAltText =
"Filter by Action Word"
;
actionWordColumn.HeaderText =
"Action Word"
;
actionWordColumn.SortExpression =
"value"
;
actionWordColumn.UniqueName =
"value"
;
actionWordColumn.HeaderStyle.Width =
new
Unit(
"10%"
);
entryTypeGrid.MasterTableView.Columns.Add(actionWordColumn);
//Create and add the column that contains the actual entry
GridBoundColumn entryColumn =
new
GridBoundColumn();
entryColumn.DataField =
"entry"
;
entryColumn.FilterControlAltText =
"Filter By Entry"
;
entryColumn.HeaderText =
"Entry"
;
entryColumn.SortExpression =
"entry"
;
entryColumn.UniqueName =
"entry"
;
entryColumn.HeaderStyle.Width =
new
Unit(
"80%"
);
entryTypeGrid.MasterTableView.Columns.Add(entryColumn);
//Create and add the column that contains the edit button
GridEditCommandColumn editColumn =
new
GridEditCommandColumn();
editColumn.ButtonType = GridButtonColumnType.LinkButton;
editColumn.UniqueName =
"EditCommandColumn"
;
editColumn.ItemStyle.Width =
new
Unit(
"15px"
);
editColumn.EditText =
"<img src='../../Images/edit.gif' border='0' title='Edit Entry'"
;
entryTypeGrid.MasterTableView.Columns.Add(editColumn);
//Create and add the column that contains the delete button
GridButtonColumn deleteColumn =
new
GridButtonColumn();
deleteColumn.ButtonType = GridButtonColumnType.LinkButton;
deleteColumn.Text =
"<img src='../../Images/action_delete.png' border='0' title='Delete Entry' />"
;
deleteColumn.ConfirmTitle =
"Are you sure?"
;
deleteColumn.ConfirmText =
"Are you sure you want to delete this item?"
;
deleteColumn.CommandName =
"Delete"
;
entryTypeGrid.MasterTableView.Columns.Add(deleteColumn);
//RadGrid >> Master Table View >> Edit Formn Settings
entryTypeGrid.MasterTableView.EditFormSettings.EditFormType = GridEditFormType.Template;
//RadGrid >> Master Table View >> Edit Form Settings >> Edit Column
entryTypeGrid.MasterTableView.EditFormSettings.EditColumn.FilterControlAltText =
"Filter EditCommandColumn1 column"
;
entryTypeGrid.MasterTableView.EditFormSettings.EditColumn.UniqueName =
"EditCommandColumn1"
;
//RadGrid >> Master Table View >> Edit Form Settings >> Form Template
EntryTypeEditFormTemplate template =
new
EntryTypeEditFormTemplate();
template.typeId = currentType.Id.ToString();
entryTypeGrid.MasterTableView.EditFormSettings.FormTemplate = template;
//RadGrid >> Client Settings
entryTypeGrid.ClientSettings.AllowRowsDragDrop =
true
;
entryTypeGrid.ClientSettings.Resizing.AllowColumnResize =
true
;
entryTypeGrid.ClientSettings.Selecting.AllowRowSelect =
true
;
entryTypeGrid.ClientSettings.Selecting.EnableDragToSelectRows =
false
;
entryTypeGrid.ClientSettings.Scrolling.AllowScroll =
true
;
entryTypeGrid.ClientSettings.Scrolling.UseStaticHeaders =
true
;
//RadGrid >> Pager Style
entryTypeGrid.PagerStyle.Mode = GridPagerMode.NumericPages;
entryTypeGrid.PagerStyle.PageButtonCount = 4;
//RadGrid >> Filter Menu
entryTypeGrid.FilterMenu.EnableImageSprites =
false
;
//RadGrid >> Header Context Menu
entryTypeGrid.HeaderContextMenu.CssClass =
"GridContextMenu GridContextMenu_Windows7"
;
//Create the SQL Data Source for the RadGrid
SqlDataSource entryTypeDS =
new
SqlDataSource();
entryTypeDS.ID =
"entryTypeDS_"
+ currentType.Id.ToString();
entryTypeDS.ConnectionString = ConfigurationManager.ConnectionStrings[Constants.DB_CONNECTION_STRING].ConnectionString;
entryTypeDS.SelectCommand =
"SELECT MonthlyEntryDetails.id, MonthlyEntryDetails.entry, MonthlyEntryDetails.entry_type_id, MonthlyEntryDetails.entry_display_order, Action_Words.value, MonthlyEntryDetails.action_word_id "
+
"FROM MonthlyEntryDetails INNER JOIN MonthlyEntries ON MonthlyEntryDetails.monthly_entries_id = MonthlyEntries.id INNER JOIN Users ON MonthlyEntries.user_id = Users.id INNER JOIN Action_Words ON "
+
"MonthlyEntryDetails.action_word_id = Action_Words.id WHERE (MonthlyEntries.id = @monthly_entry_id) AND (Users.id = @user_id) AND (MonthlyEntries.project_id = @project_id) AND "
+
"(MonthlyEntryDetails.entry_type_id = @entry_type_id) ORDER BY MonthlyEntryDetails.entry_display_order"
;
entryTypeDS.SelectParameters.Add(
new
SessionParameter(
"monthly_entry_id"
,
"monthly_entry_id"
));
entryTypeDS.SelectParameters.Add(
new
SessionParameter(
"user_id"
,
"user_id"
));
entryTypeDS.SelectParameters.Add(
new
SessionParameter(
"project_id"
,
"project_id"
));
entryTypeDS.SelectParameters.Add(
new
Parameter(
"entry_type_id"
, DbType.Int64, currentType.Id.ToString()));
//Set the data source of the grid and add to the outer div
entryTypeGrid.DataSource = entryTypeDS;
entryTypeGrid.DataBind();
outerDiv.Controls.Add(entryTypeGrid);
//Now add the data source to the outer div
outerDiv.Controls.Add(entryTypeDS);
//Finally, add the outer div to the overall container
container.Controls.Add(outerDiv);
}
void
entryTypeGrid_ItemCommand(
object
sender, GridCommandEventArgs e)
{
string
test = e.CommandName;
}
public
class
EntryTypeEditFormTemplate : IBindableTemplate
{
public
string
typeId;
public
void
InstantiateIn(Control container)
{
GridEditFormItem item = ((GridEditFormItem)(container.NamingContainer));
HtmlTable table =
new
HtmlTable();
table.Width =
"75%"
;
table.Align =
"left"
;
//Start building the table with the outer row
HtmlTableRow outerRow =
new
HtmlTableRow();
//This cell will hold a label plus the combo box that allows the user to select an action word
HtmlTableCell td_action =
new
HtmlTableCell();
HtmlTableCell td_entry =
new
HtmlTableCell();
td_action.Width =
"15%"
;
td_action.VAlign =
"top"
;
//Label for the entry
Label entryLabel =
new
Label();
entryLabel.Text =
"Entry "
;
//RadComboBox for action words
RadComboBox actionWordCombo =
new
RadComboBox();
actionWordCombo.ID =
"keyWordsBox"
;
actionWordCombo.DataSourceID =
"actionWordDS"
;
actionWordCombo.DataTextField =
"value"
;
actionWordCombo.DataValueField =
"id"
;
//Create the textbox that will hold the user's entry
RadTextBox editNameTextBox =
new
RadTextBox();
editNameTextBox.ID =
"editNameTextBox"
;
editNameTextBox.Skin =
"Windows7"
;
//Create the spell checker for the entry textbox
RadSpell checker =
new
RadSpell();
checker.ID =
"entrySpellChecker"
;
checker.ControlToCheck =
"editNameTextBox"
;
checker.Skin =
"Windows7"
;
checker.ButtonType = Telerik.Web.UI.ButtonType.ImageButton;
if
(item.ParentItem !=
null
)
{
//If we're editing an item, we need to bind the action word id and the entry name to the appropriate controls
actionWordCombo.SelectedValue = item.ParentItem.OwnerTableView.DataKeyValues[((GridDataItem)(item.ParentItem)).ItemIndex][
"action_word_id"
].ToString();
editNameTextBox.Text = item.ParentItem.OwnerTableView.DataKeyValues[((GridDataItem)(item.ParentItem)).ItemIndex][
"entry"
].ToString();
}
//Add the label and combo box to the table cell
td_action.Controls.Add(entryLabel);
td_action.Controls.Add(actionWordCombo);
//Add the textbox and spell checker to the second table cell
td_entry.Controls.Add(editNameTextBox);
td_entry.Controls.Add(checker);
//Add both table cells to the row
outerRow.Cells.Add(td_action);
outerRow.Cells.Add(td_entry);
//Add the row to the table
table.Rows.Add(outerRow);
//Create an empty row to separate the input from the buttons
outerRow =
new
HtmlTableRow();
HtmlTableCell emptyCell =
new
HtmlTableCell();
emptyCell.InnerHtml =
" "
;
outerRow.Cells.Add(emptyCell);
//Add the empty row to the table
table.Rows.Add(outerRow);
//Now we need to create the button row
outerRow =
new
HtmlTableRow();
td_action =
new
HtmlTableCell();
//Will house the save/update button
td_entry =
new
HtmlTableCell();
//Will house the cancel button
//Save/Update button
RadButton save_updateButton =
new
RadButton();
save_updateButton.ID =
"saveButton"
;
save_updateButton.Skin =
"Windows7"
;
if
(item
is
GridEditFormInsertItem)
{
//If we're dealing with an item to insert, display the button as "Insert" and give it the insert command
save_updateButton.Text =
"Insert"
;
save_updateButton.CommandName =
"PerformInsert"
;
}
else
{
//Otherwise, display as "Update" and give the update command
save_updateButton.Text =
"Update"
;
save_updateButton.CommandName =
"Update"
;
}
//Cancel Button
RadButton cancelButton =
new
RadButton();
cancelButton.ID =
"cancelButton"
;
cancelButton.Text =
"Cancel"
;
cancelButton.CommandName =
"Cancel"
;
cancelButton.Skin =
"Windows7"
;
//Add the buttons to their respective table cells
td_action.Controls.Add(save_updateButton);
td_entry.Controls.Add(cancelButton);
//Add the two table cells to the row
outerRow.Cells.Add(td_action);
outerRow.Cells.Add(td_entry);
//Add the row to the table
table.Rows.Add(outerRow);
//Finally, add the table to the overall container
container.Controls.Add(table);
}
public
IOrderedDictionary ExtractValues(System.Web.UI.Control container)
{
OrderedDictionary od =
new
OrderedDictionary();
od.Add(
"action_word_id"
, ((RadComboBox)(((GridEditFormItem)(container)).FindControl(
"keyWordsBox"
))).SelectedValue);
od.Add(
"entry"
, ((RadTextBox)(((GridEditFormItem)(container)).FindControl(
"editNameTextBox"
))).Text);
return
od;
}
}
void
EntryTypeGrid_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
RadGrid grid = sender
as
RadGrid;
string
entryTypeId = grid.ID.Substring(grid.ID.IndexOf(
'_'
) + 1);
try
{
//We need to find the SQL data source for this grid, so cycle through all of the items in the panel until we find it
SqlDataSource ds =
null
;
foreach
(RadPanelItem item
in
RadPanelBar1.Items)
{
//Try to find the control in here
ds = (SqlDataSource)item.Items[0].FindControl(
"entryTypeDS_"
+ entryTypeId);
if
(ds !=
null
) {
break
; }
}
if
(ds !=
null
)
{
grid.DataSource = ds;
}
}
catch
(Exception ex)
{
throw
ex;
}
}
protected
void
EntryTypeGrid_RowDrop(
object
sender, GridDragDropEventArgs e)
{
RadGrid grid = sender
as
RadGrid;
string
entryTypeId = grid.ID.Substring(grid.ID.IndexOf(
'_'
) + 1);
try
{
if
(
string
.IsNullOrEmpty(e.HtmlElement))
{
//We need to make sure the item is being reordered, not dragged to a different grid
if
(e.DestDataItem !=
null
&& e.DestDataItem.OwnerGridID == e.DraggedItems[0].OwnerGridID)
{
string
monthID = Session[
"monthly_entry_id"
].ToString();
//We need to find the SQL data source for this grid, so cycle through all of the items in the panel until we find it
SqlDataSource ds =
null
;
foreach
(RadPanelItem item
in
RadPanelBar1.Items)
{
//Try to find the control in here
ds = (SqlDataSource)item.Items[0].FindControl(
"entryTypeDS_"
+ entryTypeId);
if
(ds !=
null
) {
break
; }
}
if
(ds !=
null
)
{
EntryTypeCommon.RadGridReorderMonthlyEntries(grid, entryTypeId, ds, e, monthID, Session);
}
}
}
}
catch
(Exception ex)
{
throw
ex;
}
}
protected
void
EntryTypeGrid_InsertCommand(
object
source, GridCommandEventArgs e)
{
GridEditableItem itemToInsert = e.Item
as
GridEditableItem;
RadGrid grid = source
as
RadGrid;
string
entryTypeId = grid.ID.Substring(grid.ID.IndexOf(
'_'
) + 1);
Hashtable itemValues =
new
Hashtable();
itemToInsert.OwnerTableView.ExtractValuesFromItem(itemValues, itemToInsert);
//New
GridEditableItem editItem = (GridEditableItem)e.Item;
RadTextBox textBox1 = ((RadTextBox)editItem.FindControl(
"editNameTextBox"
));
string
input = EntryTypeCommon.ContainsForbidden(textBox1.Text, textBox1,
int
.Parse(Session[
"contract_id"
].ToString()));
//End New
try
{
//We need to find the SQL data source for this grid, so cycle through all of the items in the panel until we find it
SqlDataSource ds =
null
;
foreach
(RadPanelItem item
in
RadPanelBar1.Items)
{
//Try to find the control in here
ds = (SqlDataSource)item.Items[0].FindControl(
"entryTypeDS_"
+ entryTypeId);
if
(ds !=
null
) {
break
; }
}
if
(ds !=
null
)
{
EntryTypeCommon.RadGridInsertMonthlyEntryDetails(input, entryTypeId, Session, ds, grid, itemValues[
"action_word_id"
].ToString());
}
}
catch
(Exception ex)
{
throw
ex;
}
}
protected
void
EntryTypeGrid_UpdateCommand(
object
source, GridCommandEventArgs e)
{
string
id = (e.Item
as
GridEditableItem).GetDataKeyValue(
"id"
).ToString();
GridEditableItem itemToUpdate = e.Item
as
GridEditableItem;
RadGrid grid = source
as
RadGrid;
string
entryTypeId = grid.ID.Substring(grid.ID.IndexOf(
'_'
) + 1);
Hashtable itemValues =
new
Hashtable();
itemToUpdate.OwnerTableView.ExtractValuesFromItem(itemValues, itemToUpdate);
//New
GridEditableItem editItem = (GridEditableItem)e.Item;
RadTextBox textBox1 = ((RadTextBox)editItem.FindControl(
"editNameTextBox"
));
string
input = EntryTypeCommon.ContainsForbidden(textBox1.Text, textBox1, (
int
)Session[
"contract_id"
]);
//End New
try
{
//We need to find the SQL data source for this grid, so cycle through all of the items in the panel until we find it
SqlDataSource ds =
null
;
foreach
(RadPanelItem item
in
RadPanelBar1.Items)
{
//Try to find the control in here
ds = (SqlDataSource)item.Items[0].FindControl(
"entryTypeDS_"
+ entryTypeId);
if
(ds !=
null
) {
break
; }
}
if
(ds !=
null
)
{
EntryTypeCommon.RadGridUpdateMonthlyEntryDetail(id, input, ds, grid, itemValues[
"action_word_id"
].ToString(), Session);
}
}
catch
(Exception ex)
{
throw
ex;
}
}
protected
void
EntryTypeGrid_DeleteCommand(
object
source, GridCommandEventArgs e)
{
string
id = (e.Item
as
GridEditableItem).GetDataKeyValue(
"id"
).ToString();
RadGrid grid = source
as
RadGrid;
string
entryTypeId = grid.ID.Substring(grid.ID.IndexOf(
'_'
) + 1);
int
OldOrder = e.Item.ItemIndex + 1;
int
NewOrder = grid.Items.Count;
try
{
//We need to find the SQL data source for this grid, so cycle through all of the items in the panel until we find it
SqlDataSource ds =
null
;
foreach
(RadPanelItem item
in
RadPanelBar1.Items)
{
//Try to find the control in here
ds = (SqlDataSource)item.Items[0].FindControl(
"entryTypeDS_"
+ entryTypeId);
if
(ds !=
null
) {
break
; }
}
if
(ds !=
null
)
{
EntryTypeCommon.RadGridDeleteMonthlyEntryDetail(id, Session, ds, grid, OldOrder, NewOrder, entryTypeId);
}
}
catch
(Exception ex)
{
throw
ex;
}
}
protected
void
Page_init(
object
sender, EventArgs e)
{
//First, we need to build the page. This consists of building all of the entry types associated with the project
//along with RadGrids for each entry type so that the user may enter items for each of the types
List<EntryType> typeList = ProjectsHelper.GetProjectEntryTypesByProjectId(Session[Constants.SESSION_PROJECT_ID].ToString());
//We also need to build the action word data source
SqlDataSource actionWordDS =
new
SqlDataSource();
actionWordDS.ID =
"actionWordDS"
;
actionWordDS.ConnectionString = ConfigurationManager.ConnectionStrings[Constants.DB_CONNECTION_STRING].ConnectionString;
actionWordDS.SelectCommand =
"SELECT id, value FROM Action_Words WHERE (contract_id = @contract_id)"
;
actionWordDS.SelectParameters.Add(
new
SessionParameter(
"contract_id"
,
"contract_id"
));
Page.Controls.Add(actionWordDS);
if
(RadPanelBar1.Items.Count < 1)
{
//The panels have not yet been created, so we need to create them
//For each entry type that the project uses, we need to render a rad panel item
foreach
(EntryType type
in
typeList)
{
//For each entry type that the project uses, we need to render a rad panel item
RadPanelItem item =
new
RadPanelItem(type.Name);
//Add the item to the panel bar
RadPanelBar1.Items.Add(item);
}
}
//Create the inner content in each panel based on the entry type
int
counter = 0;
foreach
(EntryType type
in
typeList)
{
//For each entry type that the project uses, we need to render a rad panel item
RadPanelItem item = RadPanelBar1.Items[counter];
RadPanelItem subItem =
new
RadPanelItem();
//Create the contents of this entry type
currentType = type;
subItem.ItemTemplate =
new
CompiledTemplateBuilder(
new
BuildTemplateMethod(BuildEntryTypeTemplate));
//Add the subitem to the item
item.Items.Add(subItem);
counter++;
}
}
protected
override
void
Load_Page(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
try
{
if
(Request.Params[
"key"
] !=
null
)
{
if
(!MonthlyEntriesHelper.canEditMonthlyEntry(Request.Params[
"key"
]))
{
// //RadPanelBar1.Enabled = false;
Message.Text =
"Entries for this month have already been completed!"
; Session.Add(
"monthly_entry_id"
, Request.Params[
"key"
]);
}
else
{
RadPanelBar1.Enabled =
true
;
Message.Text =
string
.Empty;
Session.Add(
"monthly_entry_id"
, Request.Params[
"key"
]);
}
}
else
{
throw
new
MSRException(
"Request parameter is null or empty"
);
}
//Get all projects the user has access to
List<Int64> pList =
new
List<Int64>();
Int64 pID = -1;
SqlConnection conn3 =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"MonthyStatusReportConnectionString"
].ConnectionString);
conn3.Open();
SqlCommand cmd3 = conn3.CreateCommand();
cmd3.CommandText =
"SELECT project_id FROM ProjectsUsers WHERE user_id = "
+ Session[
"user_id"
];
SqlDataReader reader3 = cmd3.ExecuteReader();
while
(reader3.Read())
{
pList.Add(Int64.Parse(reader3[0].ToString()));
}
reader3.Close();
//Get the project associated with the entry
cmd3.CommandText =
"SELECT project_id FROM MonthlyEntries WHERE id = "
+ Session[
"monthly_entry_id"
];
pID = Int64.Parse(cmd3.ExecuteScalar().ToString());
//If the entry's project_id is not in the list
if
(!pList.Contains(pID))
{
//Bounce to logout
Response.Redirect(
"~/Logout.aspx?message=Access Denied."
);
}
}
catch
(Exception ex)
{
throw
ex;
}
try
{
//If the page is accessed it is no longer initiated, but pending
string
status;
string
sql =
"SELECT status_id FROM MonthlyEntries WHERE id = "
+ Session[
"monthly_entry_id"
].ToString();
string
updateSql =
"UPDATE MonthlyEntries SET status_id = 2 WHERE id = "
+ Session[
"monthly_entry_id"
].ToString();
string
historySql =
"INSERT INTO MonthlyEntryHistory VALUES ("
+ Session[
"monthly_entry_id"
] +
", -1, "
+ Session[
"user_id"
] +
", 'Initiated -> Pending', CURRENT_TIMESTAMP)"
;
SqlConnection conn =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"MonthyStatusReportConnectionString"
].ConnectionString);
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
status = cmd.ExecuteScalar().ToString();
if
(status ==
"1"
)
{
cmd.CommandText = updateSql;
cmd.ExecuteNonQuery();
cmd.CommandText = historySql;
cmd.ExecuteNonQuery();
}
conn.Close();
}
catch
(Exception ex)
{
throw
ex;
}
}
}
Again, any help would be wonderful! Thanks!
0

Andrew
Top achievements
Rank 1
answered on 22 Jun 2011, 06:30 PM
Upon further debugging, I think I may have an understanding of what is happening. When the 'PerformInsert' command is fired, the 'InstantiateIn' method of the custom edit template is executed. However, when the update button is pressed, the 'InstantiateIn' method is never executed. It looks as if when everything is built again in Page_Init the template is not being built, like the grid is taken out of edit mode. I'm not sure if this is indeed the problem, but I figured it would be good to throw in there.
Thanks!
Thanks!
0
Hi Andrew,
I am attaching a page which contains a simplified version of your Grid which executes its server-side Update and Cancel events as expected. Could you take a look and see if you can reproduce the issue with it?
Greetings,
Pavel
the Telerik team
I am attaching a page which contains a simplified version of your Grid which executes its server-side Update and Cancel events as expected. Could you take a look and see if you can reproduce the issue with it?
Greetings,
Pavel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Andrew
Top achievements
Rank 1
answered on 23 Jun 2011, 03:08 PM
I was able to reproduce the error I am having. The error comes into play when using multiple RadPanels each with its own RadGrid. I will submit a support ticket that contains a zip file with the code that produces the error.
0
Hello Andrew,
I reviewed your updated sample and was able to determine the cause for this behavior. In fact it seems I overlloked this part of your code when I created the sample from it, but it is present there as well. The problem is caused by the fact that you have disabled ViewState for the Grid. This is not supported when using custom edit form which is explained in this help article. I can suggest you to disable ViewState only for the columns if you need to. I am attaching your updated sample which now executes the events as expected. Note that you should not call Rebind() for the Grid in the method that creates it.
I hope this helps.
Kind regards,
Pavel
the Telerik team
I reviewed your updated sample and was able to determine the cause for this behavior. In fact it seems I overlloked this part of your code when I created the sample from it, but it is present there as well. The problem is caused by the fact that you have disabled ViewState for the Grid. This is not supported when using custom edit form which is explained in this help article. I can suggest you to disable ViewState only for the columns if you need to. I am attaching your updated sample which now executes the events as expected. Note that you should not call Rebind() for the Grid in the method that creates it.
I hope this helps.
Kind regards,
Pavel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.