6 Answers, 1 is accepted
0
Hello Christian,
You can cancel the PerformInsert/Cancel command in the ItemCommand event:
If you set the IsItemInserted property to true you will be able to open the insert form on initial load.
Best regards,
Daniel
the Telerik team
You can cancel the PerformInsert/Cancel command in the ItemCommand event:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.PerformInsertCommandName || e.CommandName == RadGrid.CancelCommandName)
{
e.Canceled =
true
;
//Insert new item to the DB
}
}
If you set the IsItemInserted property to true you will be able to open the insert form on initial load.
protected
void
Page_Load(
object
sender, EventArgs e)
{
RadGrid1.MasterTableView.IsItemInserted =
true
;
}
Best regards,
Daniel
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

WCRA Dev
Top achievements
Rank 1
answered on 13 Dec 2010, 04:11 PM
When I use that command I get this error message: "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control".
The insert form of the datagrid has a databound RadComboBox which is what I think it is throwing this error on.
The insert form of the datagrid has a databound RadComboBox which is what I think it is throwing this error on.
0
Hello Christian,
Could you please post some code from your project? I can give better suggestion/answer if I examine your approach.
Regards,
Daniel
the Telerik team
Could you please post some code from your project? I can give better suggestion/answer if I examine your approach.
Regards,
Daniel
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

WCRA Dev
Top achievements
Rank 1
answered on 13 Dec 2010, 11:09 PM
<
telerik:RadGrid
ID
=
"gvGrossPayroll"
runat
=
"server"
AllowAutomaticDeletes
=
"True"
AllowAutomaticUpdates
=
"True"
AllowAutomaticInserts
=
"True"
AutoGenerateColumns
=
"False"
DataSourceID
=
"SDS_Payroll"
GridLines
=
"None"
OnItemCommand
=
"gvGrossPayroll_ItemCommand"
ShowFooter
=
"True"
Skin
=
"Web20"
Width
=
"544px"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
CommandItemDisplay
=
"TopAndBottom"
DataKeyNames
=
"ID"
DataSourceID
=
"SDS_Payroll"
>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
/>
</
ExpandCollapseColumn
>
<
CommandItemSettings
/>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"id"
ReadOnly
=
"True"
UniqueName
=
"ID"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
EditFormColumnIndex
=
"0"
HeaderText
=
"Job Class Code"
UniqueName
=
"JobClass"
Visible
=
"true"
ReadOnly
=
"False"
HeaderStyle-VerticalAlign
=
"Bottom"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"JobClass"
runat
=
"server"
Text='<%# Bind("JobClass") %>'></
asp:Label
>
</
ItemTemplate
>
<
InsertItemTemplate
>
<
telerik:RadComboBox
ID
=
"ddlJobClassID"
Runat
=
"server"
AllowCustomText
=
"True"
DataSourceID
=
"SqlDataSourceDDL"
DataTextField
=
"JobClass"
DataValueField
=
"JobClassID"
EmptyMessage
=
"Please enter a job class code"
EnableViewState
=
"False"
AppendDataBoundItems
=
"true"
ErrorMessage
=
"You must enter a job class code to add a record"
MarkFirstMatch
=
"True"
ShowDropDownOnTextboxClick
=
"False"
Skin
=
"Web20"
ToolTip
=
"Enter a Job Class Code"
Width
=
"350px"
SelectedValue='<%# Bind("JobClassID") %>'>
</
telerik:RadComboBox
>
</
InsertItemTemplate
>
<
EditItemTemplate
>
<
asp:Label
ID
=
"JobClass"
runat
=
"server"
Text='<%# Bind("JobClassID") %>'></
asp:Label
>
</
EditItemTemplate
>
<
HeaderStyle
VerticalAlign
=
"Bottom"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
EditFormColumnIndex
=
"0"
HeaderText
=
"Year1"
UniqueName
=
"PayrollAmount1"
Visible
=
"true"
Aggregate
=
"Sum"
DataField
=
"PayrollAmount1"
FooterAggregateFormatString
=
"{0:C}"
HeaderStyle-Width
=
"60px"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"PayrollAmount1"
runat
=
"server"
Text='<%# Eval("PayrollAmount1", "{0:C}") %>'></
asp:Label
>
</
ItemTemplate
>
<
InsertItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"txtPayrollAmount1"
Runat
=
"server"
Culture
=
"English (United States)"
MinValue
=
"0"
NumberFormat-DecimalDigits
=
"0"
Skin
=
"Web20"
TabIndex
=
"2"
ToolTip
=
"Payroll Amount"
Type
=
"Currency"
Width
=
"100px"
Value
=
"0"
Text='<%# Bind("PayrollAmount1") %>' >
<
EnabledStyle
HorizontalAlign
=
"Right"
/>
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
InsertItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"txtPayrollAmount1"
Runat
=
"server"
Culture
=
"English (United States)"
MinValue
=
"0"
NumberFormat-DecimalDigits
=
"0"
Skin
=
"Web20"
TabIndex
=
"2"
ToolTip
=
"Payroll Amount"
Type
=
"Currency"
Text='<%# Bind("PayrollAmount1") %>' Width="100px">
<
EnabledStyle
HorizontalAlign
=
"Right"
/>
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
<
FooterStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
HorizontalAlign
=
"Right"
Wrap
=
"True"
/>
<
HeaderStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
HorizontalAlign
=
"Center"
Wrap
=
"True"
/>
<
ItemStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
HorizontalAlign
=
"Right"
Wrap
=
"True"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
EditFormColumnIndex
=
"0"
HeaderText
=
"Year2"
UniqueName
=
"PayrollAmount2"
Visible
=
"true"
DataField
=
"PayrollAmount2"
Aggregate
=
"Sum"
FooterAggregateFormatString
=
"{0:C}"
HeaderStyle-Width
=
"60px"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"PayrollAmount2"
runat
=
"server"
Text='<%# Eval("PayrollAmount2", "{0:C}") %>'></
asp:Label
>
</
ItemTemplate
>
<
InsertItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"txtPayrollAmount2"
Runat
=
"server"
Culture
=
"English (United States)"
MinValue
=
"0"
NumberFormat-DecimalDigits
=
"0"
Skin
=
"Web20"
TabIndex
=
"2"
ToolTip
=
"Payroll Amount"
Type
=
"Currency"
Value
=
"0"
Width
=
"100px"
Text='<%# Bind("PayrollAmount2") %>'>
<
EnabledStyle
HorizontalAlign
=
"Right"
/>
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
InsertItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"txtPayrollAmount2"
Runat
=
"server"
Culture
=
"English (United States)"
MinValue
=
"0"
NumberFormat-DecimalDigits
=
"0"
Skin
=
"Web20"
TabIndex
=
"2"
ToolTip
=
"Payroll Amount"
Type
=
"Currency"
Width
=
"100px"
Text='<%# Bind("PayrollAmount2") %>'>
<
EnabledStyle
HorizontalAlign
=
"Right"
/>
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
<
FooterStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
HorizontalAlign
=
"Right"
Wrap
=
"True"
/>
<
HeaderStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
HorizontalAlign
=
"Center"
Wrap
=
"True"
/>
<
ItemStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
HorizontalAlign
=
"Right"
Wrap
=
"True"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridEditCommandColumn
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
CommandName
=
"Delete"
ConfirmText
=
"Delete this payroll record?"
ImageUrl
=
"/images/delete.gif"
Text
=
"Delete"
UniqueName
=
"column3"
>
</
telerik:GridButtonColumn
>
<
telerik:GridBoundColumn
DataField
=
"MemberID"
DataType
=
"System.Int16"
UniqueName
=
"MemberID"
ReadOnly
=
"True"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
CaptionDataField
=
"MemberID"
CaptionFormatString
=
"Edit Payroll Record"
ColumnNumber
=
"1"
InsertCaption
=
"Add Payroll Record"
>
<
FormTableItemStyle
Wrap
=
"False"
/>
<
FormCaptionStyle
CssClass
=
"EditFormHeader"
/>
<
FormMainTableStyle
BackColor
=
"White"
CellPadding
=
"3"
CellSpacing
=
"0"
GridLines
=
"None"
Width
=
"100%"
/>
<
FormTableStyle
BackColor
=
"White"
CellPadding
=
"2"
CellSpacing
=
"0"
Height
=
"110px"
/>
<
FormTableAlternatingItemStyle
Wrap
=
"False"
/>
<
EditColumn
ButtonType
=
"ImageButton"
CancelText
=
"Cancel edit"
InsertText
=
"Insert Record"
UniqueName
=
"EditCommandColumn1"
UpdateText
=
"Update record"
>
</
EditColumn
>
<
FormTableButtonRowStyle
CssClass
=
"EditFormButtonRow"
HorizontalAlign
=
"Right"
/>
</
EditFormSettings
>
</
MasterTableView
>
<
ClientSettings
AllowDragToGroup
=
"True"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Web20"
EnableImageSprites
=
"True"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SDS_Payroll"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:DB_Connect_Website %>"
SelectCommand="sp_AAH_Payroll" SelectCommandType="StoredProcedure"
InsertCommand="sp_AAH_Payroll_Insert" InsertCommandType="StoredProcedure"
DeleteCommand="sp_AAH_Payroll_Delete" DeleteCommandType="StoredProcedure"
UpdateCommand="sp_AAH_Payroll_Update" UpdateCommandType="StoredProcedure">
<
SelectParameters
>
<
asp:SessionParameter
DefaultValue
=
"0"
Name
=
"MemberID"
SessionField
=
"MemberID"
Type
=
"Int32"
/>
</
SelectParameters
>
<
DeleteParameters
>
<
asp:ControlParameter
Name
=
"ID"
Type
=
"Int32"
ControlID
=
"gvGrossPayroll"
PropertyName
=
"SelectedValue"
> </
asp:ControlParameter
>
</
DeleteParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"JobClassID"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"PayrollAmount1"
Type
=
"Decimal"
/>
<
asp:Parameter
Name
=
"PayrollAmount2"
Type
=
"Decimal"
/>
</
UpdateParameters
>
<
InsertParameters
>
<
asp:SessionParameter
SessionField
=
"MemberID"
Name
=
"MemberID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"JobClassID"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"PayrollAmount1"
Type
=
"Decimal"
/>
<
asp:Parameter
Name
=
"PayrollAmount2"
Type
=
"Decimal"
/>
</
InsertParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSourceDDL"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:DB_Connect_Website %>"
SelectCommand="sp_AASI_JobClassCodes" SelectCommandType="StoredProcedure">
</
asp:SqlDataSource
>
0

WCRA Dev
Top achievements
Rank 1
answered on 15 Dec 2010, 08:17 PM
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.PerformInsertCommandName || e.CommandName == RadGrid.CancelCommandName)
{
e.Canceled = true;
//Insert new item to the DB
}
}
0
Hello Christian,
You can clear the form by invoking OwnerTableView.Rebind as demonstrated below:
Best regards,
Daniel
the Telerik team
You can clear the form by invoking OwnerTableView.Rebind as demonstrated below:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.PerformInsertCommandName || e.CommandName == RadGrid.CancelCommandName)
{
e.Canceled =
true
;
e.Item.OwnerTableView.Rebind();
}
}
Best regards,
Daniel
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.