I'm sure this is a duplicate request, but I can't find what I'm looking for. I'm hoping someone can point me in the right direction.
I need a demo/forum post with an example of a dynamic user control. Based upon the type of record being edited, I want the control to render itself differently for each type. (Most of my work is in the code behind as well, so demos with stuff in the mark up doesn't fit too well.)
For example,
I have a data grid, lets say a grid of a automobiles. Each automobile record has an automobile-type-indicator (T=truck, C=Convertable, W=Wagon, S=Sedan, ....).
When the user drills down on a truck recod .. I pass the indicator "T" to the user control. I have this wired up and working in the Item Created Event.
The user control then says, "hey I'm a truck" so it renders the truck panel which shows a prompt for the size of the truck bed, towing package, etc.
When the user clicks a Convertable record, the user control says, "hey, I'm a convertable" so it now hides the truck stuff and shows a panel with a drop down for rag top or hard top, transmission type, etc.
I can do some of this, but the user control's page life cycle is different when I put it into an inline edit vs. just putting it on a standard page. Stuff like setting a label value within page load doesn't render, instead I have to hook a data binding event in order to do stuff in the code behind..
My lastest challenge is when, say I'm showing the convertable panel. The user says, "lets make it a truck instead" and changes the autoType drop down from convertable to truck. I then execute a onSelectedValueChange event, to show/hide text boxes concerning truck options. However, none of the new panels render.
I can hit this code when the drop down changes, but I can't seem to do anything to effect the rendering of the control.
so if anyone has any examples to help guide me, I'd love to see them. ... thank you very much.
I need a demo/forum post with an example of a dynamic user control. Based upon the type of record being edited, I want the control to render itself differently for each type. (Most of my work is in the code behind as well, so demos with stuff in the mark up doesn't fit too well.)
For example,
I have a data grid, lets say a grid of a automobiles. Each automobile record has an automobile-type-indicator (T=truck, C=Convertable, W=Wagon, S=Sedan, ....).
When the user drills down on a truck recod .. I pass the indicator "T" to the user control. I have this wired up and working in the Item Created Event.
| protected void grdDefinition_ItemCreated(object sender, GridItemEventArgs e) | |
| { | |
| if (e.Item is GridEditableItem && e.Item.IsInEditMode) | |
| { | |
| AutomobilSelector userControl = (AutomobilSelector )e.Item.FindControl(GridEditFormItem.EditFormUserControlID); | |
| userControl.AutoTypeId = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["auto_type_id"].ToString(), CultureInfo.InvariantCulture); | |
| } | |
| ] | |
The user control then says, "hey I'm a truck" so it renders the truck panel which shows a prompt for the size of the truck bed, towing package, etc.
When the user clicks a Convertable record, the user control says, "hey, I'm a convertable" so it now hides the truck stuff and shows a panel with a drop down for rag top or hard top, transmission type, etc.
I can do some of this, but the user control's page life cycle is different when I put it into an inline edit vs. just putting it on a standard page. Stuff like setting a label value within page load doesn't render, instead I have to hook a data binding event in order to do stuff in the code behind..
My lastest challenge is when, say I'm showing the convertable panel. The user says, "lets make it a truck instead" and changes the autoType drop down from convertable to truck. I then execute a onSelectedValueChange event, to show/hide text boxes concerning truck options. However, none of the new panels render.
| protected void ddlAutoType_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) | |
| { | |
| pnlTruck.Visible = false; | |
| pnlConvertable.Visible = false; | |
| pnlSedan.Visible = false; | |
| switch (ddlAutoType.SelectedValue.ToString(CultureInfo.InvariantCulture)) | |
| { | |
| case "T": | |
| pnlTruck.Visible = true; | |
| break; | |
| case "S": | |
| pnlSedan.Visible = true; | |
| break; | |
| case "C": | |
| pnlConvertable.Visible = true; | |
| break; | |
| default: | |
| break; | |
| } | |
| } | |
so if anyone has any examples to help guide me, I'd love to see them. ... thank you very much.