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

GridBoundColumn ReadOnly="true"

2 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Syed M Ali Shah
Top achievements
Rank 1
Syed M Ali Shah asked on 31 Aug 2009, 10:52 AM
Hi,

I am having problem in accessing value from a column with ReadOnly="True". Actually i don't want a column (e.g. PriceID) to be displayed in Insert/Edit Form, but i need its value to update the records in database. Currently if I set the readonly="false" it gets the value , but when its "true" then value in PriceID remains NULL.

Please help me in writing code , so that I can access value from a Readonly="true" column, and it should not be visible in grid and in editmode.

Thanks

Cheers, ALi

2 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 31 Aug 2009, 11:08 AM
Hi Syed,

Please review the following forum post, which elaborates on similar subject and let me know if you need additional assistance.
http://www.telerik.com/community/forums/aspnet-ajax/grid/accessing-a-read-only-databound-column-grideditableitem-returns-nothing.aspx

I hope this helps.

Kind regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Shinu
Top achievements
Rank 1
answered on 31 Aug 2009, 11:12 AM
Hi Syed,

One suggestion would be setting the DataKeyNames property of RadGrid and gettuing the value using " GetDataKeyValue " method as shown below.

ASPX:
 
 . . . 
<Columns> 
    <telerik:GridBoundColumn  ReadOnly="true" DataField="CustomerID" HeaderText="CustomerID" SortExpression="CustomerID" 
        UniqueName="CustomerID"
    </telerik:GridBoundColumn> 
     . . . 
</Columns> 
 . . . 

C#:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
    { 
        GridEditableItem item = (GridEditableItem)e.Item; 
        Response.Write(item.GetDataKeyValue("CustomerID")); 
    } 

-Shinu.
Tags
Grid
Asked by
Syed M Ali Shah
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Shinu
Top achievements
Rank 1
Share this question
or