WebListBox cant detect Selected item is this a bug?

3 replies. Last post: June 10, 2011 2:25 AM by Riendy Setiadi
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Neil TurnerMember

I'm trying to get the selected item of a WebListBox on post back so i can add one item in a weblistbox to another WebListBox but the selected item isn't being detected selected when the button is clicked

Code below

               <table cellspacing="0" cellpadding="0">

                    <tr valign="top">

                    <td>

                        <ISWebEssentials:WebListBox ID="WebListBox1" runat="server" Height="160px" 

                            Width="250px" >

                            <Items>

                                <ISWebEssentials:WebListBoxItem Name="WebListBoxItem0" Text="1" />

                                <ISWebEssentials:WebListBoxItem Name="WebListBoxItem1" Text="2" />

                                <ISWebEssentials:WebListBoxItem Name="WebListBoxItem2" Text="3" />

                                <ISWebEssentials:WebListBoxItem Name="WebListBoxItem3" Text="4" ToolTip="4" />

                            </Items>

                            </ItemStyle>


                        </ISWebEssentials:WebListBox></td>

                    <td width="60" align="center" valign="middle">

                        <asp:Button ID="Button1" runat="server" Text="Add" ToolTip="Add item" onclick="btnAddItem_Click" /><br /><br />

                    </td>

                    <td>

                        <ISWebEssentials:WebListBox ID="WebListBox2" runat="server" Height="160px" Width="250px">

                            <Items>

                                <ISWebEssentials:WebListBoxItem Name="WebListBoxItem0" Text="a" />

                            </Items>

                        </ISWebEssentials:WebListBox></td>

                    </tr>

                </table>



Code behind


        protected void btnAddItem_Click(object sender, EventArgs e)

        {

            foreach (WebListBoxItem wli in WebListBox1.Items)

            {

                if (wli.Selected)

                {

                    WebListBox2.Items.Add(wli);

                }

            }

        }



All times are GMT -5. The time now is 9:49 PM.
Previous Next