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

Read-only datasource?

4 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 14 Jul 2009, 04:30 PM
Hi all,
I'm probably being really thick here...

I have an object-based datasource, which is a List<MyObject>, which I've got displaying nicely in my Grid.

I don't want the user to be able to add new rows to the grid, but I do want to have the Refresh button above the grid.

Is there a setting for the Grid to make it read-only (thus removing the Add new record button), or is it something I need to do with my datasource?

Thanks,

James

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 Jul 2009, 04:29 AM
Hello James,

You can remove just the AddNewRecord button from the command item above the grid using the following code:
c#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    if (e.Item is GridCommandItem) 
    { 
        Button spriteAddButton = e.Item.FindControl("AddNewRecordButton"as Button; 
        spriteAddButton.Visible = false
  
        LinkButton addButton = e.Item.FindControl("InitInsertButton"as LinkButton; 
        addButton.Visible = false
    } 

Thanks
Princy.
0
James
Top achievements
Rank 1
answered on 15 Jul 2009, 07:14 AM
Hi Princy,
Thanks - that's just what I needed.

James
0
sudheer
Top achievements
Rank 2
answered on 15 Jul 2009, 09:05 AM

Hi

you can acheive same thing with single property as below

 

CommandItemDisplay

 

="None" 

inside

 

<

 

MasterTableView GroupLoadMode="Client"  CommandItemDisplay="None" TableLayout="Fixed" Width="100%">

 

 

 

No need to go itemcreated it decrease perfomance............... 

0
James
Top achievements
Rank 1
answered on 15 Jul 2009, 09:36 AM
Hi Sudheer,
Thanks - but won't that also remove the Refresh button? I want the Refresh button, but not the Add new record button.
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
James
Top achievements
Rank 1
sudheer
Top achievements
Rank 2
Share this question
or