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

[Solved] change item align style of automatic generated grid column

2 Answers 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Binod
Top achievements
Rank 1
Binod asked on 19 May 2009, 04:46 PM
HI Telerik

i am binding grid like this through code

GridView1.DataSource = tblsalesData;

GridView1.DataBind();

and in .aspx page it is like this

 

 

<telerik:RadGrid ID="GridView1" runat="server" AutoGenerateColumns="true" Width="940px">

 

 

 

 

 

 

<ItemStyle HorizontalAlign="right" Font-Size="10px" Font-Names="verdana" />

 

 

 

 

 

 

<AlternatingItemStyle Font-Size="10px" Font-Names="verdana" HorizontalAlign="right"/>

 

 

 

 

 

 

<HeaderStyle HorizontalAlign="Center" Font-Bold="true" Font-Size="10px"

 

 

 

 

 

 

Font-Names="Verdana"></HeaderStyle>

 

 

 

 

 

 

</telerik:RadGrid>

 

 

 

My problem is that,
 1. i want to change the horizental align to left only for 1st column.
 2. want to put thousand seperator for only first two rows data.

please guide me how to achieve this result. 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 May 2009, 04:57 AM
Hi Binod,

You  may access the autogeneratedcolumn in the ColumnCreated event and set the desired ItemStyle to the column as shown below.

CS:
 
 protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
    { 
        if (e.Column.UniqueName == "ProductName"
        { 
            e.Column.ItemStyle.HorizontalAlign = HorizontalAlign.Left; 
        } 
    } 


Shinu
0
Binod
Top achievements
Rank 1
answered on 20 May 2009, 05:28 AM
thanks a lot for your quick reply..
Tags
Grid
Asked by
Binod
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Binod
Top achievements
Rank 1
Share this question
or