This is a migrated thread and some comments may be shown as answers.

Listbox template - problem to do search and access item content

2 Answers 64 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Daniel Aquere
Top achievements
Rank 2
Daniel Aquere asked on 13 Jun 2011, 03:08 PM
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 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 16 Jun 2011, 02:04 PM
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.

0
Daniel Aquere
Top achievements
Rank 2
answered on 23 Jun 2011, 03:09 PM
Hi Dimitar,

Thanks, works fine!

Abraço

Daniel
Tags
ListBox
Asked by
Daniel Aquere
Top achievements
Rank 2
Answers by
Dimitar Terziev
Telerik team
Daniel Aquere
Top achievements
Rank 2
Share this question
or