Changing delete text on RADGrid autogenerated column

9 posts, 0 answers
  1. Jason Thacker
    Jason Thacker avatar
    18 posts
    Member since:
    Apr 2009

    Posted 26 Aug 2009 Link to this post

    Is there any way of changing the default "delete" "edit" "insert" "cancel" etc. text on a RADGrid with auto-generated delete and edit columns? I need to change these to a non-english language and I am struggling with trying to apply localization to the RADGrid control.

    Thanks in advance,

    Jason
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Aug 2009 Link to this post

    Hello Jason,

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Luigi
    Luigi avatar
    1 posts
    Member since:
    Jun 2009

    Posted 14 May 2010 Link to this post


    Please,

    Could I get the example in VB?

    thank you very much
    Luigi
  5. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 14 May 2010 Link to this post

    Hello 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.
  6. antonio
    antonio avatar
    3 posts
    Member since:
    Nov 2010

    Posted 14 Dec 2010 Link to this post

    Hi,

    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????
  7. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 15 Dec 2010 Link to this post

    Hello antonio,

    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
    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.
  8. antonio
    antonio avatar
    3 posts
    Member since:
    Nov 2010

    Posted 15 Dec 2010 Link to this post

    Thanks Sebastian,

    the solution works fine!


    Regards,
    Antonio Bastida Cruz
  9. Chris
    Chris avatar
    5 posts
    Member since:
    May 2014

    Posted 03 Jun 2015 in reply to Sebastian Link to this post

    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?

  10. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 08 Jun 2015 Link to this post

    Hi Chris,

    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
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017