GridView control CommandField EditText/DeleteText

I have a GridView contol with rows which can be edited and deleted.
Using Edit Field command I can set EditText and DeleteText for a CommanField. But how to change these values at run time in VB code? I need this for translations to other languages.
Who is Participating?
burakiewiczConnect With a Mentor Commented:
i think you need to do this after the databind but not 100% sure
replace the 0 with the position of your command column and the name of your gridview for gridview1
Dim cf As CommandField = CType(GridView1.Columns(0), CommandField)
cf.EditText = ""

You have a few options to accomplish this.  You can convert the CommandField into a TemplateField, which will give you the following markup:

<asp:TemplateField ShowHeader="False">
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"

You can than add an event handler on the LinkButton PreRender event to modify the Text, or you can hook into the GridView's DataBound event and use the code burakiewicz recommended.  Or you can set it declaritively using the <%$ %> syntax.  The following MSDN article dicuss how to use this declarative syntax for Localization on ASP.NET controls: when you a series of Culture specific Resource files.
IpZeroAuthor Commented:
It worked fine in Page_Load event. :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.