Center RadNumericTextBox in RadGrid column

1 Answer 26 Views
Grid NumericTextBox
Laurie
Top achievements
Rank 1
Iron
Laurie asked on 11 Dec 2023, 05:30 PM

I'm trying to center a RadNumericTextBox in a RadGrid column and it is not working. HEre's what my grid looks like:


        <telerik:RadGrid ID="rgGrid" runat="server" OnNeedDataSource="rgGrid_NeedDataSource" EnableAjaxSkinRendering="true"
            AutoGenerateColumns="False" CellSpacing="0" GridLines="None" MasterTableView-CommandItemDisplay="None" OnPreRender="rgGrid_PreRender" OnItemDataBound="rgGrid_ItemDataBound">
            <MasterTableView DataKeyNames="ProjectDataIndividualsBenefitedId" AllowFilteringByColumn="false" AllowSorting="false" AllowPaging="false" PageSize="1000">
                <Columns>
                    <telerik:GridBoundColumn DataField="Question" HeaderText="Question" UniqueName="Question">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn UniqueName="Target" HeaderText="Target" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <telerik:RadNumericTextBox ID="rntbTarget" runat="server" DataType="System.Int32" MinValue="0" NumberFormat-DecimalDigits="0" DbValue='<%# Eval("TargetBenefited") %>' Width="50" CssClass="form-control"></telerik:RadNumericTextBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
               </Columns>
          </MasterTableView>
     </telerik:RadGrid>

And what I'm getting is the following:

Any ideas?

1 Answer, 1 is accepted

Sort by
1
Accepted
Vasko
Telerik team
answered on 12 Dec 2023, 03:47 PM

Hello Laurie,

Thank you for sharing the code snippet.

I tested it and on my end, the numeric text box was centered inside the column:

I suppose some CSS styles might be interfering with the alignment of the textbox, possibly the form-control CSS class that is added to the textbox. Could you check to see if that's the cause of the misalignment? 

Kind regards,
Vasko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Laurie
Top achievements
Rank 1
Iron
commented on 28 Dec 2023, 05:50 PM

Yes, that did it! Thanks, Vasko!
Tags
Grid NumericTextBox
Asked by
Laurie
Top achievements
Rank 1
Iron
Answers by
Vasko
Telerik team
Share this question
or