Programmatically create template with child items.
Hi Everyone
I’m trying to create a template layout for the ‘WebDropDown’, programmatically. Does anyone know if this can be done?
I populate my ‘WebDropDown’ controls using a generic subroutine like this.
For Each objMLPD_WorksTempEmp_Item In objMLPD_WorksTempEmp_IList
objIListItem = New Infragistics.Web.UI.ListControls.DropDownItem()
objIListItem.Text = objMLPD_WorksTempEmp_Item.Surname _
& " " & objMLPD_WorksTempEmp_Item.FirstName & " " _
& "[" & objMLPD_WorksTempEmp_Item.ClockNumber & "]"
objIListItem.Value = objMLPD_WorksTempEmp_Item.SQLWorkTeamList
icboFindGangClockNumber.Items.Add(objIListItem)
Next
This works well, but the rows look a bit unformatted. I would like to modify my subroutine so that it will generate a Template block for each ListItem.
<ig:WebDropDown ID="icboFindGangClockNumber" runat="server" Width="95%" DropDownAnimationType="EaseOut"
DropDownContainerHeight="300px" DropDownContainerMaxHeight="300px"
DropDownContainerWidth="300px" Height="21px"
StyleSetName="SkanskaStyleSet1" StyleSetPath="~/ig_res/"
MultipleSelectionType="Keyboard">
<Items>
<ig:DropDownItem Selected="False" Text="Surname FirstName [abcd1234]" Value="1">
<Template>
<div class="WebDropDownHolder">
<div class="WebDropDownLeft"> Surname </div>
<div class="WebDropDownRight"> abcd1234 </div>
<div class="WebDropDownCenter"> FirstName </div>
</div>
</Template>
</ig:DropDownItem>
</Items>
<ItemTemplate>
Item Template
</ItemTemplate>
</ig:WebDropDown>
I have had a good look at the properties of the ‘Infragistics.Web.UI.ListControls.DropDownItem()’. I noticed the objIListItem.Template property, but don’t know how to add my <div> definition to it.
Any help very much appreciated.
Regards
PenPal1999.
Still hoping for some help, I've tried a few things, like creating a server control, which inherits 'Infragistics.Web.UI.ListControls.WebDropDown'. This works well but I still have the problem of generating the 'Template' section of the DropDownItem, programmatically.
Can anyone from the 'Infragistics team' tell me if it is possible to generate this section programatically? Just a simple yes or no will do.
In my server control I can now fully control the generation of the control itself (mybase.RenderContents(writer)). And in this RenderContents sub, I can create and add each DropDownItem and add them to mybase.items collection.
Yes it is possible. You can use an ASP.NET CompiledTemplateBuilder :
someDropDownItem.Template = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildMyTemplate));
then:
void BuildMyTemplate(Control container)
{
HtmlGenericControl div = new HtmlGenericControl"("div");
container.Controls.Add(div);
/// and so on ...
}
Hope it helps.
Angel
Hi,
Iam looking for something similar.
Could you please provide me a sample in code behind with webdatagrid - templatedatafield - itemtemplate - text box bonded with HtmlGenericControl.
Its urgent. Please revert asap.