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

[Solved] Inconsistent Button Text

4 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 2
Phil asked on 27 Jan 2010, 11:47 PM
Hi:
Varying from in-line and edit-form the text does not match the values in editcolumn tag.
Attached is an example:
<%@ Page Language="C#" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="Telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<script runat="server"
    // 
    protected void RadioCheckedChanged(object sender, System.EventArgs e) 
    { 
        switch ((sender as RadioButton).ID) 
        { 
            case "RadioButton1": 
                { 
                    shippersGrid.MasterTableView.EditMode = GridEditMode.EditForms; 
                    RadioButton2.Checked = false
                    break; 
                } 
            case "RadioButton2": 
                { 
                    shippersGrid.MasterTableView.EditMode = GridEditMode.InPlace; 
                    RadioButton1.Checked = false
                    break; 
                } 
        } 
        shippersGrid.Rebind(); 
    } 
    // 
    protected void shippersDataSource_Deleted(object sender, SqlDataSourceStatusEventArgs e) 
    { 
        if (e.Exception != null) 
        { 
            messageLabel.Text = e.Exception.Message; 
            e.ExceptionHandled = true
        } 
    } 
    // 
    protected void shippersDataSource_Updated(object sender, SqlDataSourceStatusEventArgs e) 
    { 
        if (e.Exception != null) 
        { 
            messageLabel.Text = e.Exception.Message; 
            e.ExceptionHandled = true
        } 
    } 
    // 
    protected void shippersDataSource_Inserted(object sender, SqlDataSourceStatusEventArgs e) 
    { 
        if (e.Exception != null) 
        { 
            messageLabel.Text = e.Exception.Message; 
            e.ExceptionHandled = true
        } 
    } 
</script> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
</head> 
<body> 
    <form id="form1" runat="server"
        <Telerik:RadScriptManager ID="RadScriptManager1" runat="server"
        </Telerik:RadScriptManager> 
        <div style="float: left; margin-left: 30px;"
            <asp:RadioButton ID="RadioButton1" AutoPostBack="True" Text="In-forms editing mode" 
            runat="server" Checked="True" oncheckedchanged="RadioCheckedChanged" /> 
        </div> 
        <div style="float: left;"
            <asp:RadioButton ID="RadioButton2" AutoPostBack="True" Text="In-line editing mode" 
            runat="server" oncheckedchanged="RadioCheckedChanged" /> 
        </div> 
        <telerik:radgrid  
            ID="shippersGrid" runat="server"  
            DataSourceID="shippersDataSource"  
            GridLines="None"  
            AllowPaging="True"  
            AutoGenerateColumns="False" 
            allowautomaticdeletes="True"  
            allowautomaticinserts="True"  
            allowautomaticupdates="True"  
            Skin="Office2007"  
            > 
            <MasterTableView  
                CommandItemDisplay="Top"  
                DataSourceID="shippersDataSource"  
                > 
                <Columns> 
                    <Telerik:GridEditCommandColumn EditText="Edit" /> 
                    <Telerik:GridTemplateColumn HeaderText="Shipper Via" UniqueName="ShipperIDColumn" AllowFiltering="False" > 
                        <ItemTemplate> 
                            <asp:Label ID="ShipperIDLabel" runat="server" Text='<%# Eval("ShipperID") %>' /> 
                        </ItemTemplate> 
                        <EditItemTemplate> 
                            <asp:Label ID="ShipperIDLabel" runat="server" Text='<%# Eval("ShipperID") %>' /> 
                        </EditItemTemplate> 
                    </Telerik:GridTemplateColumn> 
                    <Telerik:GridBoundColumn DataField="CompanyName" UniqueName="CompanyNameColumn" HeaderText="Company Name" /> 
                    <Telerik:GridBoundColumn DataField="Phone" UniqueName="PhoneColumn" HeaderText="Phone" /> 
                    <Telerik:GridButtonColumn Text="Delete" CommandName="Delete"  
                        UniqueName="DeleteColumn"  
                        ConfirmText="Are you sure you want to delete this data?" /> 
                </Columns> 
                <ExpandCollapseColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
                </ExpandCollapseColumn> 
                <RowIndicatorColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
                </RowIndicatorColumn> 
                <EditItemStyle CssClass="EditedTelerikGrid"/> 
                <EditFormSettings > 
                    <EditColumn  
                        UniqueName="EditCommandColumn" 
                        InsertText="Save" 
                        UpdateText="Save" 
                        CancelText="Cancel" 
                        > 
                    </EditColumn> 
                    <FormMainTableStyle CssClass="EditedTelerikGrid" /> 
                </EditFormSettings> 
                <CommandItemSettings AddNewRecordText="Add"  RefreshText="Refresh" /> 
            </MasterTableView> 
            <FilterMenu EnableTheming="True" Skin="Office2007"
                <CollapseAnimation Duration="200" Type="OutQuint" /> 
            </FilterMenu> 
        </telerik:radgrid> 
        <br /> 
        <asp:SqlDataSource ID="shippersDataSource" runat="server"  
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"  
            DeleteCommand="DELETE FROM [Shippers] WHERE [ShipperID] = @ShipperID"  
            InsertCommand="INSERT INTO [Shippers] ([CompanyName], [Phone]) VALUES (@CompanyName, @Phone)"  
            SelectCommand="SELECT [ShipperID], [CompanyName], [Phone] FROM [Shippers]"  
             
            UpdateCommand="UPDATE [Shippers] SET [CompanyName] = @CompanyName, [Phone] = @Phone WHERE [ShipperID] = @ShipperID"  
            ondeleted="shippersDataSource_Deleted"  
            onupdated="shippersDataSource_Updated"  
            oninserted="shippersDataSource_Inserted"
            <DeleteParameters> 
                <asp:Parameter Name="ShipperID" Type="Int32" /> 
            </DeleteParameters> 
            <UpdateParameters> 
                <asp:Parameter Name="CompanyName" Type="String" /> 
                <asp:Parameter Name="Phone" Type="String" /> 
                <asp:Parameter Name="ShipperID" Type="Int32" /> 
            </UpdateParameters> 
            <InsertParameters> 
                <asp:Parameter Name="CompanyName" Type="String" /> 
                <asp:Parameter Name="Phone" Type="String" /> 
            </InsertParameters> 
        </asp:SqlDataSource> 
        <asp:Label ID="messageLabel" runat="server" Text="" ></asp:Label> 
    </form> 
</body> 
</html> 
 
How can I set the in-place link values.

Thanks Phil

4 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 02 Feb 2010, 12:18 PM
Hello Phil,

You could get and change the in-place Add/Update/Cancel links on ItemDataBound event with the following code snippet:

void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem && e.Item.IsInEditMode)
        {
            GridDataItem item = (GridDataItem)e.Item;
            LinkButton updateButton = item.FindControl("UpdateButton") as LinkButton;
            if (updateButton != null)
            {
                updateButton.Text = "UpdateButton";
            }
            LinkButton cancelButton = item.FindControl("CancelButton") as LinkButton;
            if (cancelButton != null)
            {
                cancelButton.Text = "CancelButton";
            }
            LinkButton insertButton = item.FindControl("PerformInsertButton") as LinkButton;
            if (insertButton != null)
            {
                insertButton.Text = "InserButton";
            }
        }
    }

Additionally I am sending you a simple example based on your code, which illustrates how to achieve the desired functionality.

I hope this helps.

All the best,
Radoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Phil
Top achievements
Rank 2
answered on 02 Feb 2010, 11:31 PM
Hi:
Why is the Grid not retaining this information?  This would indicate a bug to me.  Thanks for the work-around.
Phil
0
Radoslav
Telerik team
answered on 05 Feb 2010, 03:58 PM
Hello Phil,

When the EditMode property is set to EditForms, the edit controls are part of the grid edit form. In that case the settings in the EditFormSettings tag tag valid and you could set the InsertText, UpdateText and CancelText properties as below:

<EditFormSettings>
   <EditColumn  UniqueName="EditCommandColumn" InsertText="Save" UpdateText="Save"  CancelText="Cancel">
   </EditColumn>
</EditFormSettings>

On the other hand, when the EditMode property is set to InPlace, the edit controls belong to the edit column and the settings in the EditFormSettings tag are not valid for the controls in that column.
To set a default InsertText, UpdateText and CancelText in EditMode="InPlace" , you need to add them into the telerik:GridEditCommandColumn declaration:

<Telerik:GridEditCommandColumn InsertText="Save" UpdateText="Save" CancelText="Cancel" EditText="Edit" />

I hope this helps.

Sincerely yours,
Radoslav
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Phil
Top achievements
Rank 2
answered on 10 Feb 2010, 02:29 AM
Great explaination, ... thanks
Tags
Grid
Asked by
Phil
Top achievements
Rank 2
Answers by
Radoslav
Telerik team
Phil
Top achievements
Rank 2
Share this question
or