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

column to be right aligned during editmode.

1 Answer 16 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erin
Top achievements
Rank 1
Erin asked on 28 Oct 2013, 12:16 PM
Hi..
I want to make a column to be right aligned during editmode.

Erin.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 28 Oct 2013, 12:23 PM
Hi Erin,

Please try the following code snippet.

ASPX:
<telerik:RadGrid ID="myRadGrid" runat="server" OnItemDataBound="myRadGrid_ItemDataBound" . . >
    <MasterTableView EditMode="InPlace">
        <Columns>
            <telerik:GridNumericColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID">
            </telerik:GridNumericColumn>
          
            <telerik:GridTemplateColumn HeaderText="ShipCountry">
                <ItemTemplate>
                    <%# Eval("ShipCountry")%>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ShipCountry")%>'></asp:TextBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void myRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem dataItem = (GridEditableItem)e.Item;
        RadNumericTextBox rdnmrctxtbx = (RadNumericTextBox)dataItem["OrderID"].Controls[0];  //Access a NumericBoundColumn   
        rdnmrctxtbx.Style.Add("text-align", "right");
        
        TextBox txt1 = (TextBox)dataItem.FindControl("TextBox1"); //Access a TemplateColumn Textbox
        txt1.Style.Add("text-align", "right");
    }
}

Thanks,
Princy

Tags
Grid
Asked by
Erin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or