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

disable Add New Record and Refresh link

11 Answers 265 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 22 Apr 2008, 10:41 AM

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.

If there is any other way please guide me.

Thanks & Regards,
Hardik.

11 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 22 Apr 2008, 10:44 AM
Hi Hardik,

You can use ItemCreated to modify default command item. Here is an example:

if(e.Item is GridCommandItem)
{
    LinkButton LinkButton1 = e.Item.FindControl("InitInsertButton");
    LinkButton1.Enabled = false;
    LinkButton LinkButton2 = e.Item.FindControl("RebindGridButton");
    LinkButton2.Enabled = false;
}

All the best,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hardik Mehta
Top achievements
Rank 1
answered on 22 Apr 2008, 11:14 AM

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.

Thanks & Regards,
Hardik.

0
Vlad
Telerik team
answered on 22 Apr 2008, 11:25 AM
Hello Hardik

You can find the example attached.

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hardik Mehta
Top achievements
Rank 1
answered on 22 Apr 2008, 11:43 AM

Hello, 

I am sorry but it is not working as it has to. I am getting error like 'Object reference not set to an instance of an object.’
If possible please provide me working error free solution.

Thanks & regards,
Hardik

0
Hardik Mehta
Top achievements
Rank 1
answered on 22 Apr 2008, 11:45 AM

Here are the details for the exception I am getting


 

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 15:         {
Line 16:             LinkButton LinkButton1 = (LinkButton)e.Item.FindControl("InitInsertButton");
Line 17: LinkButton1.Enabled = false;Line 18:             LinkButton LinkButton2 = (LinkButton)e.Item.FindControl("RebindGridButton");
Line 19:             LinkButton2.Enabled = false;
0
Vlad
Telerik team
answered on 22 Apr 2008, 11:59 AM
Hello Hardik,

I'm not sure how did you get this exception? From my project or from your project?

All the best,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hardik Mehta
Top achievements
Rank 1
answered on 22 Apr 2008, 01:14 PM

Yes dear, just from your code I have got that error. Can you just check the code you have sent me as a solution? I think you have send it to me without checking the code.

Kindly provide your comments, 

Thanks & Regards,
Hardik

0
Vlad
Telerik team
answered on 22 Apr 2008, 01:45 PM
Hello Hardik,

Here is a screenshot from the running version of my code.

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hardik Mehta
Top achievements
Rank 1
answered on 23 Apr 2008, 04:54 AM

The sample that you have sent is using assemblies having version 3.5.
Actually we are using RadGrid.Net2.dll having version '4.6.2.0'. And one more thing, We are developng this application in Asp.Net 2.0. So now if you can help me by keeping these boundaries in mind, I will be very thankful….J

Thanks & Regards,
Hardik

0
Shinu
Top achievements
Rank 2
answered on 23 Apr 2008, 12:13 PM
Hi Hardik,

Try setting CommandItemDisplay to None if you dont want to display AddNewRecord and Refresh button.

Shinu.
0
lakshmi
Top achievements
Rank 1
answered on 26 May 2011, 08:56 PM
thanks shinu

worked for me
Tags
Grid
Asked by
Hardik Mehta
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Hardik Mehta
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
lakshmi
Top achievements
Rank 1
Share this question
or