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

[Solved] Disable Add New Record and Refresh link

3 Answers 237 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hardik Mehta
Top achievements
Rank 1
Hardik Mehta asked on 23 Apr 2008, 01:09 PM

Hello, 

I want to disable Add New Record and Refresh link which on the top of the RadGrid. Actually I have some limitations and so i can not implement ''CommandItemTemplate' to do this.

we are using RadGrid.Net2.dll having version '4.6.2.0'. and we are developng this application in Asp.Net 2.0.

If there is any way please guide me.

Thanks & Regards,
Hardik.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Apr 2008, 01:22 PM
Hi Hardik,

Try the following code snippet to hide the AddNewRecord button.

CS:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
 
        if (e.Item is GridCommandItem)  
        {  
            GridCommandItem cmditm = (GridCommandItem)e.Item;  
            LinkButton lnkbtn1 = (LinkButton)cmditm.FindControl("InitInsertButton");  
            lnkbtn1.Visible = false;  
 
        }  
   }  
 


Thanks
Princy.
0
Hardik Mehta
Top achievements
Rank 1
answered on 23 Apr 2008, 01:55 PM

Hello, 

Thanks for the reply. When I executed this code I didn’t find the control I was looking for.
Can you do me a favor, can you provide me the sample working example to disable Add New Record and Refresh controls.

I hope the code that you will provide will have
RadGrid.Net2.dll with version '4.6.2.0' (or any new RadGrid version which can be used in Asp.Net 2.0 or any new RadGrid DLL compatible with RadGrid.Net2.dll version '4.6.2.0') and you web application would be in Asp.Net 2.0.

Waiting for your reply,

Thanks & Regards,
Hardik.

0
Shinu
Top achievements
Rank 2
answered on 24 Apr 2008, 06:39 AM
Hi Hardik,

Can you give a try with the following code snippet and see whether you are able to achieve the desired effect?

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridCommandItem) 
        { 
            GridCommandItem cmditm = (GridCommandItem)e.Item; 
            //to hide AddNewRecord button 
            LinkButton lnkbtn1 = (LinkButton)cmditm.Cells[0].Controls[0].Controls[0].Controls[0].Controls[0]; 
            lnkbtn1.Visible = false
 
            //to hide Refresh button 
            LinkButton lnkbtn2 = (LinkButton)cmditm.Cells[0].Controls[0].Controls[0].Controls[1].Controls[0]; 
            lnkbtn2.Visible = false
 
        } 
  } 


Thanks
Shinu.
Tags
Grid
Asked by
Hardik Mehta
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Hardik Mehta
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or