Hi all. I am using Visual Studio 08 SP1 with Telerik Asp.net ajax 2010 version..
Using below link as prototype, I would like to allow edit/delete functions for certain rows (Say allow edit/delete to those Rows only if City = "London", if not edit/delete will be cancelled/not allowed).
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/commanditem/defaultcs.aspx
Below is my radgrid and onitemcommand for cancel.
Thanks
---------
<
telerik:RadGrid
ID
=
"RadGrid1"
AllowAutomaticUpdates
=
"true"
AllowAutomaticDeletes
=
"true"
DataSourceID
=
"SessionDataSource1"
AllowSorting
=
"True"
AutoGenerateColumns
=
"true"
AllowPaging
=
"True"
GridLines
=
"None"
runat
=
"server"
ShowFooter
=
"True"
AllowMultiRowSelection
=
"True"
PageSize
=
"7"
AllowMultiRowEdit
=
"True"
AllowAutomaticInserts
=
"True"
OnItemDeleted
=
"RadGrid1_ItemDeleted"
onitemcommand
=
"RadGrid1_ItemCommand"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
/>
<
MasterTableView
Width
=
"100%"
CommandItemDisplay
=
"Top"
DataSourceID
=
"SessionDataSource1"
DataKeyNames
=
"CustomerID"
>
<
CommandItemTemplate
>
<
div
style
=
"padding: 5px 5px;"
>
Custom command item template
<
asp:LinkButton
ID
=
"btnEditSelected"
runat
=
"server"
CommandName
=
"EditSelected"
Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"Images/Edit.gif"
/>Edit selected</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"LinkButton2"
runat
=
"server"
CommandName
=
"InitInsert"
Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"Images/AddRecord.gif"
/>Add new</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"LinkButton3"
runat
=
"server"
CommandName
=
"PerformInsert"
Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"Images/Insert.gif"
/> Add this Customer</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"LinkButton1"
OnClientClick
=
"javascript:return confirm('Delete all selected customers?')"
runat
=
"server"
CommandName
=
"DeleteSelected"
><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"Images/Delete.gif"
/>Delete selected customers</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"LinkButton4"
runat
=
"server"
CommandName
=
"RebindGrid"
><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"Images/Refresh.gif"
/>Refresh customer list</
asp:LinkButton
>
</
div
>
</
CommandItemTemplate
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
EnableDragToSelectRows
=
"True"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
// Here I need help to allow edit/delete for only Customers from London...
if (e.CommandName == RadGrid.EditSelectedCommandName)
{
e.Canceled = true;
}
}