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

How do I Set ItemStyle-HorizontalAlign dynamically

2 Answers 186 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amol
Top achievements
Rank 2
Amol asked on 12 Feb 2009, 11:52 AM

Hi All,

I have  a  auto generator column grid, now i want to set horizontal align for columns , each column has different alignment depending on condition.

Please help me to fix my problem.

Thanks,
Amol

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 12 Feb 2009, 12:26 PM
Hello,

You can try out the following code to set the HorizontalAlign property for columns:
cs:
 
 protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)  
        {  
            if (col.UniqueName == "ProductName") //where ProductName is the datafield of the column in the database 
            {  
                col.ItemStyle.HorizontalAlign = HorizontalAlign.Right;  
            }  
              
        }  
    }  

Thanks
Princy
0
Amol
Top achievements
Rank 2
answered on 13 Feb 2009, 06:55 AM
It works fine.
Thanks a lot Princy.


Tags
Grid
Asked by
Amol
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Amol
Top achievements
Rank 2
Share this question
or