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

all rows in edit modem + alternating colors

3 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
glenn
Top achievements
Rank 1
glenn asked on 18 Jul 2008, 12:43 PM
Hi,

Is it possible to put all rows in edit mode and still have alternating row colors?

thx in advance
Glenn

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 18 Jul 2008, 01:27 PM
Hello Glenn,

The only way to do this would be to manually override the CssClass property of the edited items as they are created. In the ItemDataBound event you can get a reference to your item and based on its ItemIndex being even or odd, you can set its CssClass property to one of the two css classes - for regular and alternating items.
Please see if this works for you.

Regards,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
glenn
Top achievements
Rank 1
answered on 18 Jul 2008, 02:16 PM
Yes this is working. I still have one problem. How can i change the color of the textboxes(from the edit mode) to the color of the row?
Can i get a reference to them in the ItemDataBound event?

thx in advance,
Glenn
0
Princy
Top achievements
Rank 2
answered on 21 Jul 2008, 05:22 AM
Hi Glenn,

Try out the following code snippet and see if it helps.

CS:
 int counter = 0;  
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
        {  
              
            GridEditableItem edititem = (GridEditableItem)e.Item;  
 
            TextBox txtbx = (TextBox)edititem["columnUniqueName"].Controls[0];  
            if (counter % 2 == 0) //even row    
            {  
                txtbx.BorderColor = System.Drawing.Color.Red;  
            }  
            else //odd row    
            {  
                txtbx.BorderColor = System.Drawing.Color.Blue;  
            }  
            counter++;    
              
        }  
   } 

Thanks
Princy.
Tags
Grid
Asked by
glenn
Top achievements
Rank 1
Answers by
Veli
Telerik team
glenn
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or