Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


change alignment of template column (textbox) in Datagrid

Posted on 2003-11-17
Medium Priority
Last Modified: 2011-09-20

I have a datagrid with several template columns that are databound.  I was able to change the alignment of the template columns IF the control is a  label but if it is a textbox it doesn't change it.  Anyone has an idea how to change it during design time or run time?  Thanks.

Question by:IceMan713
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 9766844
Windows application or Web application?

Cause in Windows Application, you can do this with the tablestyle and columnStyle's properties.


Author Comment

ID: 9767486
I'm sorry I was not clear in my first comment, this is for a Web application.

Accepted Solution

mondayblueboy earned 750 total points
ID: 9768439
You can use css style,

Design time:

Run time:
First you need to use FindControl method to get reference to the TextBox control. And then use the Styles property to change the alignment.
      TextBox1.Style.Add("text-align", "right")


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

721 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