Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
hi,
i want to access gridview in a static method but i m not able to access it so any one have any idea then plz help me to solve this problem

Eg. let i hv a gridview(gridview1) and a button(button1) in my page.now i have a static method i.e LoadGV

public static LoadGV()
{
gridview1.Datasource=SomeData;
gridview1.DataBind();
}

in button click i want to call this method.


Thnx in advance
Posted

You cannot do that. Static methods only works with static attributes and properties. gridview1 is an object of the GridView class, so the static method cannot call it!

Try to remove the key word static.

Hope it helps and explain your scenario.
 
Share this answer
 
Comments
Sourav Kumar Panda 7-Aug-12 11:03am    
Actually i want to call that method from jquery ajax call so to call a method in client side i hv 2 write dat method as static with [WebMethod] attribute so in that case i want to use dat method
Christian Amado 7-Aug-12 11:05am    
Thanks for clarify that. In this case is hard to help you. =(
Sourav Kumar Panda 7-Aug-12 11:18am    
ok no problem thnx for gave your time ....
you idiot, giving solutions does not make any sense.
 
Share this answer
 

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