SharePoint - how can make the grid editable for users that do NOT have edit rights

Asked By Bookworm on 29-Mar-12 05:58 AM

Im stuck in this problem. i create a web part which is put on a page.
the SPGrid is not editable for users that do NOT have edit rights on page.
Why is happening this? How can i fix it, because i can not set edit rights to all users?

if you have any idea pls write to me because it is very urgent.

thnx in advance.
kalpana aparnathi replied to Bookworm on 29-Mar-12 06:03 AM

Try below code for making grid editable not edit  for users .

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
      if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode) && (!e.Item.OwnerTableView.IsItemInserted))
        GridEditableItem eitem = (GridEditableItem)e.Item;
        eitem["columnUniqueName"].Enabled = false;


Somesh Yadav replied to Bookworm on 29-Mar-12 06:17 AM
check this,

Hope it helps you.
Bookworm replied to kalpana aparnathi on 29-Mar-12 06:18 AM
thnx Kalpana, my problem is that i set AutoGenerateSelectButton="True" 
but in the moment that user select a row, it gets an access denied error.
do you have any idea about this? 
Bookworm replied to Somesh Yadav on 29-Mar-12 06:20 AM
thnx but my problem is that user gets access denied error when selecting a row of the grid

this is my problem!
dipa ahuja replied to Bookworm on 29-Mar-12 12:04 PM
check the role of the user :

void BindGrid()
  //Establishing the connection
  SqlDataAdapter da = new SqlDataAdapter("Select * from people", ConnString);
  DataSet ds = new DataSet();
  //loading the records into dataset
  GridView1.DataSource = ds.Tables[0];
  SqlConnection conn = new SqlConnection("connstring");
  SqlCommand comm = new SqlCommand("SELECT role from table1 where userid=1", conn);
  string role = comm.ExecuteScalar().ToString();
    if (role != "Admin")
    //hide the edit/update column
    GridView1.Columns[3].Visible = false;