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

Please Help - Cell Text in Edit Mode

2 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 2
Jim asked on 11 Apr 2011, 07:05 PM
Hello,

I am manipulating a cell's text by using the Grid_ItemDatabound event.  See below:

If TypeOf e.Item Is GridDataItem Then
            Dim gridDataItem As GridDataItem = e.Item
            Dim quoteID = gridDataItem.Item("quoteID").Text
            Dim lineID = gridDataItem.Item("lineID").Text
            Select Case gridDataItem.Item("assortmentTypeID").Text
                Case 1000
                    gridDataItem.Item("assortmentTypeID").Text = "Text for 1000"
                Case 1002
                    gridDataItem.Item("assortmentTypeID").Text = "Text for 1002"
                Case 1003
                    gridDataItem.Item("assortmentTypeID").Text = "Text for 1003"
            End Select
        End If

This works fine until I place the grid in Edit Mode.  When I do, the text in the cell defaults back to the value coming from the datasource (1000, 1002, or 1003).  The value in this particular cell is ReadOnly, so I am not allowing edit.  How can I get the cell text to stay the way I format it regardless of what mode the grid is in?  I've tried several combinations of things using the IsInEditMode, GridEditableItem, GridEditFormItem, etc.

Thank you for any help you can offer.

Frustrated,
Jim

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Apr 2011, 06:15 AM
Hello Jim,
I suppose the assortmentTypeID ia bound column and here is the sample code to achieve the same.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)//Grid is in Inplace editmode if editmode=Editforms/PopUp use: if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
           GridEditableItem editItem = (GridEditableItem)e.Item;
           TextBox txtBox1 = (TextBox)editItem["assortmentTypeID"].Controls[0];//accessing the TextBox
           switch (gridDataItem.Item("assortmentTypeID").Text)
           {
               case 1000:
                 gridDataItem.Item("assortmentTypeID").Text = "Text for 1000";
                 break;
               case 1002:
                 gridDataItem.Item("assortmentTypeID").Text = "Text for 1002";
                 break;
               case 1003:
                 gridDataItem.Item("assortmentTypeID").Text = "Text for 1003";
                 break;
            }
        }
     }

Thanks,
Shinu.
0
Jim
Top achievements
Rank 2
answered on 13 Apr 2011, 11:06 AM
Hello Shinu,

Thank you for your help on this.  Unfortunately, I had to abandon the RadGrid for now because there are AJAX issues with it when using it in Sitefinity 4.0.  Hoping things are fixed in 4.1 so I can try your suggestion.  Thanks again for your help.

Jim
Tags
Grid
Asked by
Jim
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Jim
Top achievements
Rank 2
Share this question
or