Pass Data from Page to Control and find current loaded Control
-
Hi people, maybe somebody knows to help me out. I have 2 problems: 1. How i can pass value from Page to a User Control maybe with a Event Delegate? 2. In the code below i have a user control, but I can not access it in the code behind and in the designer it is not registered. But as soon as I remove my update panel and repater it is visible or can be accessed on it. Why?
thx a lot!
-
Hi people, maybe somebody knows to help me out. I have 2 problems: 1. How i can pass value from Page to a User Control maybe with a Event Delegate? 2. In the code below i have a user control, but I can not access it in the code behind and in the designer it is not registered. But as soon as I remove my update panel and repater it is visible or can be accessed on it. Why?
thx a lot!
-Muc_ wrote:
1. How i can pass value from Page to a User Control maybe with a Event Delegate?
- One simple way you can do it, Have a public property in usercontrol which takes the value that you want and pass it from the page.
-Muc_ wrote:
2. In the code below i have a user control, but I can not access it in the code behind and in the designer it is not registered.
We cannot access directly any item that is in repeater.If you want to access it then you have to find it dynamically from codebehind using findcontrol.You can find it in itemdatabound of repeater. Actually when we bind a datasource to repeater, the number of rows is created based on data and for every row sepearte control is created, so to access these controls you can access using find control in itemadatabound. for details Have a look
Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators
-
-Muc_ wrote:
1. How i can pass value from Page to a User Control maybe with a Event Delegate?
- One simple way you can do it, Have a public property in usercontrol which takes the value that you want and pass it from the page.
-Muc_ wrote:
2. In the code below i have a user control, but I can not access it in the code behind and in the designer it is not registered.
We cannot access directly any item that is in repeater.If you want to access it then you have to find it dynamically from codebehind using findcontrol.You can find it in itemdatabound of repeater. Actually when we bind a datasource to repeater, the number of rows is created based on data and for every row sepearte control is created, so to access these controls you can access using find control in itemadatabound. for details Have a look
Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators
-
Butt how should i add a EventHandler from usercontrol in my aspx page in the Repeater if I can not find it?
You add a event itemdatabound in the repeater,which is on your page.And in this function, find out your usercontrol as
SkillGroupControl ctrl= (SkillGroupControl)e.Item.FindControl("SkillGroup");
Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators
-
You add a event itemdatabound in the repeater,which is on your page.And in this function, find out your usercontrol as
SkillGroupControl ctrl= (SkillGroupControl)e.Item.FindControl("SkillGroup");
Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators
I had this event already knew that but not if I set a property of the control is static that the value is also reingespeichert. I had this event already knew that but not if I set a property of Control that the value is static stores even.
protected virtual void RepeaterGroup_ItemdataBound(object sender, RepeaterItemEventArgs e)
{
MuMSkillGroup group = (MuMSkillGroup)e.Item.DataItem;
SkillGroupControl currentGoup = (SkillGroupControl)e.Item.FindControl("Skillgroup");
}But thx a Lot!