Solved

Asp.net GridView control CommandField EditText/DeleteText

Posted on 2009-04-07
3
1,423 Views
Last Modified: 2012-05-06
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.
0
Comment
Question by:IpZero
3 Comments
 
LVL 16

Accepted Solution

by:
burakiewicz earned 500 total points
Comment Utility
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 = ""
0
 
LVL 8

Expert Comment

by:ppittle
Comment Utility
lpZero,

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">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Edit"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>

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: http://msdn.microsoft.com/en-us/library/fw69ke6f(VS.80).aspx when you a series of Culture specific Resource files.
0
 

Author Closing Comment

by:IpZero
Comment Utility
It worked fine in Page_Load event. :)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now