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

Color of row items in edit mode

3 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 05 Apr 2012, 04:33 PM
I have a radgrid that is automatically put it edit mode on pre_render

foreach (GridItem item in radgrdResultDetail.MasterTableView.Items)
       {
           if (item is GridEditableItem)
           {
               GridEditableItem editableItem = item as GridDataItem;
               editableItem.Edit = true;
           }
       }

When i try and style the rows nothing works, all the rows are white as opposed to alternating colours when not in edit mode. I have tried the following in the itemdatabound (works in non edit mode) but none of the styling appears when the grid/row is in edit mode

if (Item["Status"].Text == "Reject")
        {
            foreach (GridColumn col in radgrdResultDetail.MasterTableView.AutoGeneratedColumns)
            {
                Item[col.UniqueName].ForeColor = Color.Red;
            }
        }
    }

Any help on this would be greatly appreciated.

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 06 Apr 2012, 08:02 AM
Hello Michel,

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            // for normal mode
            GridDataItem item = e.Item as GridDataItem;
            item["ID"].ForeColor = System.Drawing.Color.Red;
        }
 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            //for edit mode
            GridEditableItem item = e.Item as GridEditableItem;
            (item["ID"].Controls[0] as TextBox).ForeColor = System.Drawing.Color.Yellow;
        }
}

  protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        foreach (GridItem item in RadGrid1.MasterTableView.Items)
        {
            if (item is GridEditableItem)
            {
                GridEditableItem editableItem = item as GridDataItem;
                editableItem.Edit = true;
            }
        }
        RadGrid1.Rebind();
}


Thanks,
Jayesh Goyani
0
Michael
Top achievements
Rank 1
answered on 06 Apr 2012, 09:58 AM
Jayesh, i have tried this but the colour of the text is still default. I have put break points in and the code is being hit but no styling is being applied.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 06 Apr 2012, 01:36 PM
Hello Michael,

Can you please provide grid's code?
So can we can able to find issue in your code.

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Michael
Top achievements
Rank 1
Share this question
or