How do I Set ItemStyle-HorizontalAlign dynamically

3 posts, 1 answers
  1. Amol
    Amol avatar
    57 posts
    Member since:
    Apr 2008

    Posted 12 Feb 2009 Link to this post


    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. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Feb 2009 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Amol
    Amol avatar
    57 posts
    Member since:
    Apr 2008

    Posted 13 Feb 2009 Link to this post

    It works fine.
    Thanks a lot Princy.


Back to Top