When the user click "Add new row", I need to disable it

Thread is closed for posting
5 posts, 0 answers
  1. rema43001
    rema43001 avatar
    14 posts
    Member since:
    Sep 2009

    Posted 19 Oct 2009 Link to this post

    Hello:
    When the user click "Add new row", I need to disable it,
    for example,
    if the user click on "Add New Row" the program execute a routine that return a boolean,
    if the routine return true then "Add new row" must to display a message "You can't add more rows".
    And the inputs for insert don't must appear.

    Can you help me?

    Thanks.
  2. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 20 Oct 2009 Link to this post

    You could try the following piece of code after the boolean is returned:

     
    GridCommandItem myItem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];  
    ((LinkButton)myItem.FindControl("InitInsertButton")).Visible = false;  
                  

    To disable that particular button. You could then perhaps take use of a RadAlert or another RadWindow to display your error message.


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. rema43001
    rema43001 avatar
    14 posts
    Member since:
    Sep 2009

    Posted 21 Oct 2009 Link to this post

    Thanks Schlurk

    It's possible to acces the EditButton?

    GridCommandItem myItem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];  
    ((LinkButton)myItem.FindControl("EditButton")).Visible = false;

    this return the error {"Object reference not set to an instance of an object."}
    Can you help me?

    Thanks
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Oct 2009 Link to this post

    Hello,

    I hope you want  to hide the autogenerated EditButton in the grid from code behind. If so you can try following code in ItemDataBound event.

    CS:
     
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem myItem = (GridDataItem)e.Item; 
            ((LinkButton)myItem.FindControl("AutoGeneratedEditButton")).Visible = false
        } 

    -Shinu.
  6. rema43001
    rema43001 avatar
    14 posts
    Member since:
    Sep 2009

    Posted 11 Nov 2009 Link to this post

    Thanks Schlurk, for the code hide the InitInsertButton

    GridCommandItem myItem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];  
    ((LinkButton)myItem.FindControl("InitInsertButton")).Visible = false; 

    But is necessary to hide the Image next to "Add new row" that have the same function.

    Anyone know how to hide this?

    Thanks.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017