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

[Solved] RadGrid InPlace Edit

3 Answers 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saurabh Srivastava
Top achievements
Rank 1
Saurabh Srivastava asked on 20 Aug 2009, 09:32 AM
Hi,

I am using thre inPlace edit mode for my grid. I have all but one column which are defined as readonly. I noticed that when I click on edit, if the readonly column has a NULL/Blank, the display is messed up. A black line appears on the row if the column has values whereas it disappears if the column is blank/NULL.

This looks really odd in my scenario. Is there a way this can be corrected?

Thanks,
Saurabh

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Aug 2009, 10:24 AM
Hi Saurabh,

Try adding ' ' to the readonly field while in edit mode as shown below.

ASPX:
 
     <telerik:GridBoundColumn DataField="SupplierID" ReadOnly="true"  DataType="System.Int32" HeaderText="SupplierID" 
                            SortExpression="SupplierID" UniqueName="SupplierID"
                        </telerik:GridBoundColumn> 

CS:
 
 protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            editItem["SupplierID"].Text = "&nbsp;"
        } 
 
    } 
 


Shinu
0
Saurabh Srivastava
Top achievements
Rank 1
answered on 20 Aug 2009, 10:58 AM
Hi Shinu,

Thanks for the response. A quick clarification before I implement it:

Shouldn't I be checking the value first and then doing the &nbsp assignment. Because if I do it straightaway, I guess if there is a value in the column, it would be overwritten (although I haven't tried it out).

Regards,
Saurabh
0
Accepted
Shinu
Top achievements
Rank 2
answered on 20 Aug 2009, 11:21 AM
Hi Saurabh,

You can check the following condition in the ItemDataBound event.

CS:
 
 protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            Literal literal = (Literal)editItem["SupplierID"].Controls[1]; 
            if(literal.Text==""
             editItem["SupplierID"].Text = "&nbsp;"
        } 
 
    } 


Thanks
Shinu
Tags
Grid
Asked by
Saurabh Srivastava
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Saurabh Srivastava
Top achievements
Rank 1
Share this question
or