Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to find the gridview control placed in formview
It looks like i have found the control in formview but I am not able to bind the
data coming from the dataset

GridView gvSizePrice = (GridView)fvProduct.FindControl("gdvSizePrice");
             gvSizePrice.DataSource = ds;
             gvSizePrice.DataBind();


can some one help
Posted
Updated 9-May-11 19:31pm
v2

try

fvProduct.Row.FindControl("gdvSizePrice");


Thanks,
Hemant
 
Share this answer
 
v2
Comments
suhailnoorpawane 10-May-11 2:35am    
when i run the data is not getting bind i cant see grid view in runtime
Hemant__Sharma 10-May-11 5:01am    
My bad i didn't pay attention to "i have found the control" thing but to the title "How to Find Control in FormView ItemTemplate". What type of answer do you expect with such a title?

Anyways .. in what event are you fetching the gridview control.. you can do this in Item_created event of formview, just make sure you are not binding formview after binding gridview otherwise it will override gridview.
you can also confirm the datasource is getting attached by "Quick watch" ing gvSizePrice's datasource property after gvSizePrice.DataBind();

Please take care of the title next time and down voting an answer.

Thanks,
Hemant
suhailnoorpawane 10-May-11 5:55am    
sorry buddy
Hemant__Sharma 10-May-11 6:20am    
Hey.. don't be. But when you find the answer please update this question what was the problem and what was the solution. It will help others to understand possible failure and its solution for such a scenario.

Regards,
Hemant
suhailnoorpawane 10-May-11 8:10am    
I dont know I wasnt able to solve it.
But i did it the other way.
I placed my gridview outside the Formview control. And so the need to find it was not there


I think it may be the because of the Different Modes Formview Contain.

Thanks for reply anyways
A little more dynamic (when in a FormView event, like DataBound):

GridView gv = (GridView)((FormView)sender).Row.FindControl("GridView1");
 
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