Thanks in advance,
Jason
8 Answers, 1 is accepted
You can customize the Edit and Delete texts as shown below:
c#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
GridDataItem item = (GridDataItem)e.Item; |
((LinkButton)item["AutoGeneratedEditColumn"].Controls[0]).Text = "CustomEdit"; |
((LinkButton)item["AutoGeneratedDeleteColumn"].Controls[0]).Text = "CustomDelete"; |
} |
} |
And to customize the Insert , Update and Cancel buttons, you can try out the following:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" AutoGenerateDeleteColumn="true" AutoGenerateEditColumn="true" OnItemDataBound="RadGrid1_ItemDataBound"> |
<MasterTableView DataSourceID="SqlDataSource1" EditMode="InPlace" CommandItemDisplay="Top"> |
<EditFormSettings> |
<EditColumn UniqueName="EditCommandColumn1" InsertText="CustomInsert" CancelText="CustomCancel" UpdateText="CustomUpdate" > |
</EditColumn> |
</EditFormSettings> |
.... |
Thanks
Princy.
Please,
Could I get the example in VB?
thank you very much
Luigi
You can use our online code converter to convert your code-snippets.
VB:
Protected
Sub
RadGrid1_ItemDataBound(sender
As
Object
, e
As
GridItemEventArgs)
Handles
RadGrid1.ItemDataBound
If
TypeOf
e.Item
Is
GridDataItem
Then
Dim
item
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
DirectCast
(item(
"AutoGeneratedEditColumn"
).Controls(0), LinkButton).Text =
"CustomEdit"
DirectCast
(item(
"AutoGeneratedDeleteColumn"
).Controls(0), LinkButton).Text =
"CustomDelete"
End
If
End
Sub
Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I tested this solution and works fine, but exist some way to change this text only for some row values???
For example:
id name depto
edit 1 Terry Sales
view 2 George Marketing
view 3 Christine Marketing
edit 4 Robert Sales
The thext "edit" only change to "view", when value for depto field is "Marketing".
Is this posible????
Try the following code modification to see whether this produces the desired result:
Protected
Sub
RadGrid1_ItemDataBound(sender
As
Object
, e
As
GridItemEventArgs)
Handles
RadGrid1.ItemDataBound
' provided that your depto column has UniqueName="depto"
If
TypeOf
e.Item
Is
GridDataItem
Then
Dim
item
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
If
item[
"depto"
].Text =
"Marketing"
Then
DirectCast
(item(
"AutoGeneratedEditColumn"
).Controls(0), LinkButton).Text =
"view"
End
If
End
Sub
Regards,
Sebastian
the Telerik team
the solution works fine!
Regards,
Antonio Bastida Cruz
I get an error on the "If item["depto"]" item cannot be converted to boolean. Otherwise, this looks to be the solution I am in search of, but cant get past this item value. Anyone know what the issue may be?
Generally, you will need to use the Controls[0] approach in order to access any autogenerated column controls:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows
If you have different requirements or further instructions, please elaborate on your specific scenario so we can provide you with a more accurate solution.
Regards,
Eyup
Telerik
Hi Eyup/Telerik team,
I have a slightly different issue with the Autogenerated Delete column in the 2-level hierarchical Radgrid. I want to position the Autogenerated delete column in the end of all the dynamic columns of a datasource.
Can you please help me as in how to align the Autogenerated delete column at the last of all the dynamic columns in Parent and Child both the tables?
Thanks & Regards,
Dhaval Doshi.
Hi Dhaval,
By default, the AutoGeneratedDeleteColumn is rendered after any columns that are created declaratively in the Grid markup. Yet, the same is rendered before the AutoGeneratedColumns.
If you want to control the order of all the rendered columns you will need to declare them all in the markup of the RadGrid ordered in the desired way and avoid using the AutoGeneratedColumns.
One more option is to manually generate the structure of the Grid programmatically and create and add the Columns to the TableView in the desired order but this approach could get quite tricky when it comes to hierarchical RadGrid, see