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

How to restrict user not to edit required columns in the following scenario

1 Answer 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ranganath
Top achievements
Rank 1
Ranganath asked on 10 Oct 2008, 12:48 PM

Hi,

I want to restrict user to not to Edit Few Columns. Here I am sending the Example which I am trying to implement the above functionality.

<telerik:RadGrid ID="RadGrid1" 

        Width="97%" Skin="Office2007"

            ShowStatusBar="True" AllowSorting="True" PageSize="7" GridLines="None" AllowPaging="True"

            runat="server" AllowAutomaticUpdates="True"

         AutoGenerateColumns="False"

        OnDataBound="RadGrid1_DataBound" onneeddatasource="RadGrid1_NeedDataSource">

            <PagerStyle Mode="NumericPages" />

            <MasterTableView Width="100%" DataKeyNames="OrderID,ProductID" EditMode="InPlace" AutoGenerateColumns="false">

              <Columns>

                <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" ReadOnly="True" HeaderStyle-Width="20%" />

                <telerik:GridBoundColumn UniqueName="ProductID" DataField="ProductID" HeaderText="ProductID" ReadOnly="True" HeaderStyle-Width="15%" />

                <telerik:GridBoundColumn UniqueName="Quantity" DataField="Quantity" HeaderText="Quantity" HeaderStyle-Width="20%" />

                <telerik:GridDropDownColumn UniqueName="CbxUnitPrice" HeaderText="Unit price"

                 ListTextField="UnitPrice" ListValueField="UnitPrice" DataField="UnitPrice" HeaderStyle-Width="25%" />

                <telerik:GridBoundColumn UniqueName="Discount" DataField="Discount" HeaderText="Discount" HeaderStyle-Width="20%" />

              </Columns>

            </MasterTableView>

            <ClientSettings>

                <ClientEvents OnRowClick="RowClick" OnRowDblClick="RowDblClick"

                    OnGridCreated="GridCreated"   />

            </ClientSettings>

        </telerik:RadGrid>

 

C#:

 

    //Declare a global DataTable dtTable

    public static DataTable dtTable;

    //Declare a global SqlConnection SqlConnection

    //public SqlConnection SqlConnection = new SqlConnection("Data Source=local;Initial Catalog=Northwind;User ID=**");

    public static SqlConnection SqlConnection = new SqlConnection("server=.;database=Northwind;uid=sa;pwd=password");

    //Declare a global SqlDataAdapter SqlDataAdapter

    public SqlDataAdapter SqlDataAdapter = new SqlDataAdapter();

    //Declare a global SqlCommand SqlCommand

    public SqlCommand SqlCommand = new SqlCommand();

protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)

    {

        string StrCon = "SELECT TOP 18 * FROM  OrdersDetails";

        SqlDataAdapter dap = new SqlDataAdapter(StrCon, SqlConnection);

        DataSet ds = new DataSet();

        dap.Fill(ds, "OrdersDetails");

        this.RadGrid1.DataSource = ds.Tables[0];

       

       

    }

 

In the above Example I want restrict user to not to edit “Quantity” Column.

Please Guide me in this regards.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Oct 2008, 03:59 AM
Hi,

Set the ReadOnly property to true for the required column to prevent editing.

ASPX:
<telerik:GridBoundColumn UniqueName="Quantity"  ReadOnly="true" DataField="Quantity" HeaderText="Quantity" HeaderStyle-Width="20%" > 
                    </telerik:GridBoundColumn> 


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