Click here to Skip to main content
14,734,054 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am using Gridview to show some data, but i am facing some problem in aligning the text in grid view boundfield.

I have to justify the text in gridview column, i am using below code

<asp:BoundField DataField="Description" HeaderText="Description" HeaderStyle-HorizontalAlign="left" ItemStyle-HorizontalAlign="Justify" />

But it is not working. Any suggestion most welcome
Karthik Harve 14-Jun-12 4:26am
May be the CSS class which you have applied to the grid, may have different text alignment. check your css class.
Vani Kulkarni 14-Jun-12 4:44am
I agree with Karthik. Please check your CSS.

Dennis Romero Xavier 7-Dec-17 9:44am
I tried this but it shows error.
<asp:BoundField DataField="MC" HeaderText="MC" SortExpression="MC">
     <ItemStyle HorizontalAlign="Center" />

Just post the answer, instead of a hyperlink to another website!!
CHill60 15-Sep-15 9:28am
It's fairly common to just post links. Firstly, there may be other discussions and/or alternatives discussed. Secondly it encourages the understanding that most of the questions asked here could be answered by the OP themselves with a little research.
If you are going to provide the answer then it's also fairly common to use the code from the OPs question and explain the differences - e.g. HeaderText should be "Description" not "MC". How does SortExpression help with justification of text, etc

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900