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

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

4 Answers 102 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
rema43001
Top achievements
Rank 1
rema43001 asked on 19 Oct 2009, 03:56 PM
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.

4 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 20 Oct 2009, 09:39 PM
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.


0
rema43001
Top achievements
Rank 1
answered on 21 Oct 2009, 09:50 PM
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
0
Shinu
Top achievements
Rank 2
answered on 22 Oct 2009, 05:38 AM
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.
0
rema43001
Top achievements
Rank 1
answered on 11 Nov 2009, 06:01 PM

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.

Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
rema43001
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
rema43001
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or