This is a migrated thread and some comments may be shown as answers.

Change Grid Editors Button's Caption

6 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
niloofar
Top achievements
Rank 1
niloofar asked on 04 Sep 2010, 10:38 AM
hi
I've got an radgrid with edit/delete/insert features enabled on. editmode for the grid is set to popup. I'd like to know How can I alter edit window's Update/Cancel buttons captions' to some other langueage ( destination language is Persian(Iran)) . Perferebly I would enjoy setting some properties to write my own stuff.

thanks for upcomming replies.
With Kind Regards

6 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 06 Sep 2010, 05:53 AM
Hello,


Set the properties following properties to changing the Update/Insert/Cancel text in edit/insert form.

Code:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.EditFormSettings.EditColumn.UpdateText = "Change";
    RadGrid1.MasterTableView.EditFormSettings.EditColumn.CancelText = "Close";
    RadGrid1.MasterTableView.EditFormSettings.EditColumn.InsertText = "Add";
}



-Shinu.
0
Accepted
wnl
Top achievements
Rank 1
answered on 03 Feb 2011, 12:57 PM
This example is good but when we are getting an exception (during insert/update to db):

void Grid_InsertCommand(object source, GridCommandEventArgs e)
        {
            try
            {
                // Save to db
            }
            catch (Exception ex)
            {
                e.Canceled = true;
            }
        }

 those captions are setting back to previous values. How to avoid that?
0
Veli
Telerik team
answered on 09 Feb 2011, 10:32 AM
Hello wnl,

What is the exception you are getting. Can you remove the try-catch block, get the exception message and stack trace and post it here (can be an image too).

Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
wnl
Top achievements
Rank 1
answered on 09 Feb 2011, 01:54 PM
The exception is simply: I leave empty field with primary key and try to save and of course - exception from db.
Without try/catch block the pop-up with edit has correct value of labels.

From trace:

Cannot set Column 'T_ID' to be null. Please use DBNull instead.
  at System.Data.DataRow.set_Item(DataColumn column, Object value)
  at System.Data.DataRow.set_Item(String columnName, Object value)
  at H.Common.Web.Ctl3.WebLister.rgListMainGridBase_InsertCommand(Object source, GridCommandEventArgs e)
  at Telerik.Web.UI.RadGrid.OnInsertCommand(GridCommandEventArgs e)
  at Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source)
  at Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e)
  at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
  at Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e)
  at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
  at Telerik.Web.UI.GridEditFormItem.OnBubbleEvent(Object source, EventArgs e)
  at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
  at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
  at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
  at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  at H.Common.Web.Ctl3.WebModal.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Image:
- before error: http://img200.imageshack.us/i/69467966.png
- after error: http://img97.imageshack.us/i/66857009.png
0
Veli
Telerik team
answered on 10 Feb 2011, 10:46 AM
OK, so you are catching a possible exception an invalid DB operation may throw and the button text is reverting to its original value after an exception is caught. Have you tried declaratively setting the button text:

<telerik:RadGrid>
    <MasterTableView>
        <EditFormSettings>
            <EditColumn UpdateText="Dodaj" CancelText="Anuluj" />
        </EditFormSettings>
    </MasterTableView>
</telerik:RadGrid>

If this does not help, you can programmatically find these buttons in the grid edit items and change their text:

protected void Page_PreRender(object sender, EventArgs e)
{
    var editForms = RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem);
    foreach (var item in editForms)
    {
        //find update button in edit forms
        LinkButton updateButton = item.FindControl("UpdateButton") as LinkButton;
        if (updateButton != null)
        {
            updateButton.Text = "Dodaj";
        }
 
        //find insert button in insert form
        LinkButton insertButton = item.FindControl("PerformInsertButton") as LinkButton;
        if(insertButton != null)
        {
            insertButton.Text = "Insert text here";
        }
 
        LinkButton cancelButton = (LinkButton)item.FindControl("CancelButton");
        cancelButton.Text = "Anuluj";
    }
}


Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
wnl
Top achievements
Rank 1
answered on 10 Feb 2011, 12:45 PM
Now it works perfect.
Thanks Telerik.
Tags
Grid
Asked by
niloofar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
wnl
Top achievements
Rank 1
Veli
Telerik team
Share this question
or