Rank: Member Groups: Member
Joined: 10/25/2012 Posts: 14
|
Hi,
I have an eo:ListBox as a DropDownTemplate item.
The listbox has an ASP:Table as an ItemTemplate which I would like to populate dynamically.
Problem is after postbacks the table does not retain the data in the rows and displays the same number of data rows without the data.
I hope this is not a trivial question, as I have tried to resolve it endlessly.
Thank you in advance for your advice on hos to resolve this issue.
Below is the code:
<eo:ComboBox ID="ComboBox2" runat="server" Width="675px" ControlSkinID="None" DefaultIcon="00101070" HintText="" AllowCustomText="False" AutoPostBack="True" Height="25px"> <IconAreaStyle CssText="font-family: tahoma; font-size: 11px; background-image:url(00107007); background-position: left left; background-repeat:no-repeat; vertical-align:middle;padding-left:2px; padding-right:2px;" /> <DropDownTemplate> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:crap %>" SelectCommand="...."> </asp:SqlDataSource> <eo:ListBox ID="ListBox1" runat="server" ControlSkinID="None" DataTextField="Resource" DataValueField="ResourceID" DataSourceID="SqlDataSource2" Height="200px" Width="670px"> <FooterStyle CssText="background-image:url('00106002'); background-position: left top; background-repeat: repeat; height:16px;padding-bottom:2px;padding-left:7px;padding-right:2px;padding-top:2px; margin-top:3px; height: 18px;" /> <BodyStyle CssText="border: solid 1px #dedede;" /> <ItemListStyle CssText="padding: 4px;" /> <DisabledItemStyle CssText="border-bottom: solid 1px #dedede; color: #c0c0c0; padding: 2px; padding-left:2px; padding-top:4px;padding-right:2px;padding-bottom:4px;" /> <ItemStyle CssText="border-bottom: solid 1px #dedede; padding-left: 2px; padding-right:2px; padding-top:4px; padding-bottom: 3px; background-color:white;" /> <ListBoxStyle CssText="font-family: Tahoma; font-size:12px;background-color:white;" /> <FooterTemplate> Footer </FooterTemplate> <MoreItemsMessageStyle CssText="padding:2px;" /> <HeaderStyle CssText="background-image:url('00106001');background-position-x:left;background-position-y:top;background-repeat:repeat;height:16px;padding-bottom:2px;padding-left:7px;padding-right:2px;padding-top:6px;height:19px;margin-bottom:3px;" /> <HeaderTemplate> Header </HeaderTemplate> <SelectedItemStyle CssText="background-color: #08246b; color:white; padding-left:2px; padding-top:4px;padding-right:2px;padding-bottom:4px;" /> <ItemHoverStyle CssText="border-bottom: solid 1px #dedede; padding-left: 2px; padding-right:2px; padding-top:4px; padding-bottom: 3px; background-color:#f3f7fc;" /> <ItemTemplate> <%#Eval("ResourceID")%><br />
<asp:Table ID="Table1" runat="server"> </asp:Table> </ItemTemplate> </eo:ListBox> </DropDownTemplate> <TextStyle CssText="font-family: tahoma; font-size: 11px;" /> <TextAreaStyle CssText="font-family: tahoma; font-size: 11px; border-top: solid 1px #3d7bad; border-bottom: solid 1px #b7d9ed; vertical-align:middle;padding-left:2px; padding-right:2px;" /> <ButtonStyle CssText="width:17px;height:23px;" /> <ButtonAreaStyle CssText="background-image:url(00107005);" /> <IconStyle CssText="width:16px;height:16px; display: none;" /> <ButtonAreaHoverStyle CssText="background-image:url(00107006);" /> <HintTextStyle CssText="font-style:italic;background-color:#c0c0c0;color:white;line-height:15px;" /> </eo:ComboBox>
Protected Sub ListBox1_ItemDataBound(ByVal A_0 As Object, ByVal A_1 As EO.Web.ListItemEventArgs) Handles ListBox1.ItemDataBound
If Not IsPostBack Then Dim iRow As TableRow Dim oCell As TableCell
If A_1.Item.ItemType = ListItemType.Item Then Dim lst As EO.Web.ListBoxItem = A_1.Item Dim tbl As Table = CType(lst.Container.FindControl("Table1"), Table)
With tbl oCell = New TableCell iRow = New TableRow oCell.Text = "John" iRow.Cells.Add(oCell)
oCell = New TableCell oCell.Text = "Wiley" iRow.Cells.Add(oCell)
oCell = New TableCell oCell.Text = "Winston" iRow.Cells.Add(oCell)
.Rows.Add(iRow)
oCell = New TableCell iRow = New TableRow
oCell.Text = "Duncan" iRow.Cells.Add(oCell)
oCell = New TableCell oCell.Text = "Maina" iRow.Cells.Add(oCell)
oCell = New TableCell oCell.Text = "Otlhe" iRow.Cells.Add(oCell)
.Rows.Add(iRow)
End With End If
End If End Sub
'**Note I also tried with the page load method
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, You can try to call DataBind explicitly and see if it works. It will be something like this:
Code: C#
//Get the ListBox object inside the DropDownTemplate
ListBox = DirectCast (ComboBox1.DropDownContainer.FindControl("ListBox1"), ListBox)
//DataBind ListBox
ListBox.DataBind()
Please let us know if it works for you. Thanks!
|
Rank: Member Groups: Member
Joined: 10/25/2012 Posts: 14
|
Pointed me in the right direction and worked. Tx
|