?
Solved

Changing the text on a SelectText Button on a GridView control

Posted on 2009-02-17
9
Medium Priority
?
323 Views
Last Modified: 2013-11-07
I have a GridView which shows records from a database. The first column of this has on every row a button so the user can select an item to request a quote by email.

I need to change this text as the site is being converted to multi lingual and the text is fed from a database via an other GridView control on the Page_init event with something like:

Button1.Text = GridText.Rows.Item(0).Cells(53).Text

Any ideas how I can change this text as 'selecttext' doesn't seem to be an exposed property.

<Columns>
                <asp:CommandField ShowSelectButton="True" ButtonType="Button" HeaderText="Click to ask for a Quote" SelectText="Quote Me"  >
       
                </asp:CommandField>
 
...ect...

Open in new window

0
Comment
Question by:mrnmnew
  • 5
  • 4
9 Comments
 
LVL 12

Expert Comment

by:CB_Thirumalai
ID: 23659539
Use the Button Field as below. Replace <Column_Name_Of_Data_Source> with the column name of the data source from which you get the Text value.

add an event as,
protected void KOGrid_RowCommand(Object sender, GridViewCommandEventArgs e) {
   if (e.CommandName == "QuoteME" && e.CommandArgument != null) {
        // Do required
   }
}
<asp:ButtonField AccessibleHeaderText="Grouping" ButtonType="Button" HeaderText="Click to ask for a Quote" ShowHeader="True" CommandName="QuoteME" Text="<%# DataBinder.Eval(Container, "<Column_Name_Of_Data_Source>")%>">
	<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
</asp:ButtonField>

Open in new window

0
 

Author Comment

by:mrnmnew
ID: 23668706
Almost there, thanks. But I prob was not clear in my initial description: The GridView with the button on that I want to change the text is a different Gridview with the text values depending on the language selected for the web site.

So Databinder.eval(container.dataitem"QuoteCol") doesn't reference the correct object as it is in the first GridView and not the one with the text translations in.

0
 
LVL 12

Expert Comment

by:CB_Thirumalai
ID: 23668983
You need to use the Culture information for the page.  But before that, the Text value that you intend to show on the Button should also be the required character set (I mean, it should come in the form of language characters you desire) and based on the culture info, it will be displayed.
Refer these links too.
http://www.codeproject.com/KB/aspnet/ChangeCultures.aspx
http://msdn.microsoft.com/en-us/library/bz9tc508.aspx
0
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.

 

Author Comment

by:mrnmnew
ID: 23669025
I can't even get it to build without errors. I don't think it has anything to do with character sets as it will not even read the english version of the text
0
 
LVL 12

Expert Comment

by:CB_Thirumalai
ID: 23669042
Ah! it seems that this is a different problem altogether.
0
 

Author Comment

by:mrnmnew
ID: 23669127
The code

Text="<%# DataBinder.Eval(Container, "<Column_Name_Of_Data_Source>")%>
 I replaced with

Text="<%# DataBinder.Eval(Container, "Quote Me")%>

Quote Me being the column name in the gridview called gridtext
But as this button has to be in a column in the Gridview called GridView1 I suspect that it is looking in the wrong Container.

Is this correct ?
0
 
LVL 12

Expert Comment

by:CB_Thirumalai
ID: 23669302
That is correct.  In that case, if the [Quote Me] has a common value then store it in a public variable and assign it to the button in the desired gridview.
0
 

Author Comment

by:mrnmnew
ID: 23670939
Could you show me come code to do that, preferably in VB please ?
0
 
LVL 12

Accepted Solution

by:
CB_Thirumalai earned 1500 total points
ID: 23702755
Dim QuoteMe As String as a page level public variable, where it will be accessed throughout your code.

Then, when the OnRowDataBound fires for the first gridview, get the text for QuoteMe from any of the row's cells, as you say they have common value.  Use this public QuoteMe to assign it to the Button's Text.

Actually, this is not the best way to do.  Have a function that returns the desired linguistic characters based on some input and use that to display it as Button's Text.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

864 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