Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Asp.net GridView control CommandField EditText/DeleteText

Posted on 2009-04-07
3
Medium Priority
?
1,491 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 2000 total points
ID: 24090820
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
ID: 24092748
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
ID: 31567679
It worked fine in Page_Load event. :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Screencast - Getting to Know the Pipeline
Suggested Courses

824 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