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

LinqDataSource Field Visible

2 Answers 87 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Anto (DLL Version : 2008.3.1314.35) asked on 24 Mar 2009, 09:30 AM
Hi All

I have used linqDataSource and a RadGrid.

I have fetched the data from the table and every thing is done.

The peimary key is ProductID.

So in Edit mode it is the first field. And it is Editable.

It must not be editable. What to do?

My Code is:

<

body 

 

<form id="form1" runat="server">  

 

<div 

 

<asp:ScriptManager ID="ScriptManager1" runat="server"/>  

 

<asp:LinqDataSource runat="server" ID="LinqDataSource1" ContextTypeName="AntoClassesDataContext"  

 

TableName="M_Product" EnableDelete="True" EnableInsert="True" EnableUpdate="true">  

 

</asp:LinqDataSource 

 

<telerik:RadGrid Skin="WebBlue" AutoGenerateDeleteColumn="true" AutoGenerateEditColumn="true" GroupingEnabled="true" ShowGroupPanel="true" runat="server" DataSourceID="LinqDataSource1" AllowAutomaticDeletes="true" AllowAutomaticInserts="true"

 

 

AllowAutomaticUpdates="true" AllowPaging="true" PageSize="8" AllowSorting="true"  

 

 

AllowFilteringByColumn="true" ID="RadGrid1">  

 

<MasterTableView DataKeyNames="ProductID" CommandItemDisplay="Top"> 

 

</MasterTableView 

 

<ClientSettings AllowColumnsReorder="true" AllowDragToGroup="true">  

 

</ClientSettings 

 

</telerik:RadGrid> 

 

</div 

 

</form>
</
body>

 

 

 

 


Thank you for your help.

-Anto

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Mar 2009, 10:51 AM
Hello Anto,

I hope you are using AutoGeneratedColumns. If so you can set the read only property for the primary key field column as shown in the following code to set it as non editable:
c#:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
        { 
            if (col.UniqueName == "ProductID"
            { 
                (col as GridBoundColumn).ReadOnly = true; 
            } 
        } 
    } 

Thanks
Princy.
0
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
answered on 26 Mar 2009, 08:01 AM
Hi Princy

Thank you very much

you are correct

But I didnt use it.

I dont have a .cs page.

I made autogeneratecolunms="false";

and I created the columns and I gave the property Readonly="true"

Thank you

-Anto
Tags
Scheduler
Asked by
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Share this question
or