Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can we access the gridview in static method?

if so how....
Posted
Comments
DamithSL 10-Nov-14 9:41am    
update the question with how the relevant code samples

Yes if you pass the gridview object as a parameter.
 
Share this answer
 
Comments
VICK 10-Nov-14 23:43pm    
Hey Mehdi, Can u show us exemplary chunk of code for passing gridview as parameter to static method?? As I have been using Ajax a lot but never been able to get gridview or any other form control in static method.
Yes, You can access gridview or any ASP.NET control in static method but you need to access it with the help of Parameters like following way.
Method Declartion-
private static int GetData(GridView gridView)
{
//you can do whatever you want...
return gridView.Rows.Count;
}
Calling Method-
GetData(gridViewName);//pass grid as parameter
 
Share this answer
 
Comments
yedhuvamshi 11-Nov-14 2:14am    
i am passing the gridview as parameter but webmethod is not executing......
and also no error...
Kiran Masal 11-Nov-14 12:12pm    
Please make sure you are following these steps.
1) jquery-1.10.2.min.js
2) Webmethod should be public
3) Webmethod should be static.
Rahul_Pandit 11-Nov-14 7:08am    
DId you enablepagemethod true in script manager and also enablepartialrendering true also.
yedhuvamshi 12-Nov-14 9:11am    
thank u for your response
i have tried it but it is showing some thing error...
Plz give me other solutions...
Kiran Masal 12-Nov-14 12:09pm    
i am not getting, its better to post the error message, so i can get the better idea

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900