Listbox template - problem to do search and access item content

3 posts, 0 answers
  1. Daniel Aquere
    Daniel Aquere avatar
    85 posts
    Member since:
    Mar 2011

    Posted 13 Jun 2011 Link to this post

    Hello everyone,

    I have a listbox with template and I need to do search in the item list.
    I´m using this command: (without sucess)
    RadListBox_Diretorias_0301_a.FindItemByValue

    I´m trying to read item content using this command: (without sucess)
    RadListBox_Diretorias_0301_b.Items[j].Value.ToString()

    Any help would be appreciated.

    Thanks

    Daniel

    -------------------
    asp.net code
    -------------------
    <telerik:RadListBox ID="RadListBox_Diretorias_0301_a" runat="server" Skin="Sunset"
                                                                    TransferToID="RadListBox_Diretorias_0301_b" AllowTransfer="True" AllowTransferOnDoubleClick="True"
                                                                    EnableDragAndDrop="True" LoadingPanelID="RadAjaxLoadingPanel1" SelectionMode="Multiple"
                                                                    Culture="pt-BR" Height="200px" Width="100%" BackColor="Transparent" AllowAutomaticUpdates="True"
                                                                    DataKeyField="dirempresa" DataSortField="empnome" DataSourceID="SqlDataSource_Diretorias_0301x"
                                                                    DataTextField="dirnome" DataValueField="dircodigo" OnClientTransferring="onClientTransferring"
                                                                    AutoPostBackOnTransfer="true">
                                                                    <ItemTemplate>
                                                                        <div>
                                                                            <%# DataBinder.Eval(Container.DataItem, "dirnome")%>&nbsp;-&nbsp;<%# DataBinder.Eval(Container.DataItem, "empnome")%></div>
                                                                    </ItemTemplate>
                                                                </telerik:RadListBox>
    -------------------
    C# code
    -------------------
    public class Diretorias
        {
            public string empnome { get; set; }
            public string dirnome { get; set; }
        }

        void RadListBox_Diretorias_0301_a_ItemDataBound(object sender, RadListBoxItemEventArgs e)
        {
            var serializedDataItem = GetSerializedDataItem((DataRowView)e.Item.DataItem);
            e.Item.Attributes.Add("dataItem", serializedDataItem);
        }

        private string GetSerializedDataItem(DataRowView view)
        {
            var info = new Diretorias()
            {
                empnome = (string)DataBinder.Eval(view, "empnome"),
                dirnome = (string)DataBinder.Eval(view, "dirnome")
            };

            return Serializer.Serialize(info);
        }
  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 16 Jun 2011 Link to this post

    Hello Daniel,

    Please refer to the sample project attached, showing how to find a particular item by value.

    Regards,
    Dimitar Terziev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daniel Aquere
    Daniel Aquere avatar
    85 posts
    Member since:
    Mar 2011

    Posted 23 Jun 2011 Link to this post

    Hi Dimitar,

    Thanks, works fine!

    Abraço

    Daniel
Back to Top