Solved

Asp.net GridView control CommandField EditText/DeleteText

Posted on 2009-04-07
3
1,451 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Accepted Solution

by:
burakiewicz earned 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Testing of the web services 1 78
asp.net repeater 2 36
How does this modal work? 3 33
.NET universe documentation poster 2 24
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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