Read-only datasource?

5 posts, 0 answers
  1. James
    James avatar
    29 posts
    Member since:
    Sep 2008

    Posted 14 Jul 2009 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Jul 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. James
    James avatar
    29 posts
    Member since:
    Sep 2008

    Posted 15 Jul 2009 Link to this post

    Hi Princy,
    Thanks - that's just what I needed.

    James
  5. sudheer
    sudheer avatar
    109 posts
    Member since:
    Dec 2008

    Posted 15 Jul 2009 Link to this post

    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............... 

  6. James
    James avatar
    29 posts
    Member since:
    Sep 2008

    Posted 15 Jul 2009 Link to this post

    Hi Sudheer,
    Thanks - but won't that also remove the Refresh button? I want the Refresh button, but not the Add new record button.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017