Please Help - Cell Text in Edit Mode

3 posts, 0 answers
  1. Jim
    Jim avatar
    8 posts
    Member since:
    Sep 2010

    Posted 11 Apr 2011 Link to this post


    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.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Apr 2011 Link to this post

    Hello Jim,
    I suppose the assortmentTypeID ia bound column and here is the sample code to achieve the same.
    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";
                   case 1002:
                     gridDataItem.Item("assortmentTypeID").Text = "Text for 1002";
                   case 1003:
                     gridDataItem.Item("assortmentTypeID").Text = "Text for 1003";

  3. Jim
    Jim avatar
    8 posts
    Member since:
    Sep 2010

    Posted 13 Apr 2011 Link to this post

    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.

Back to Top