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

RADListBox Bind Description Text

1 Answer 58 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gourangi
Top achievements
Rank 1
Gourangi asked on 17 Feb 2009, 09:04 AM
Hi,

How can I bind a runtime value in description text property of ListBox Item !
Like there should be databind property (field name) for description text !

Regards,
Divyesh Chapaneri

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 17 Feb 2009, 05:03 PM
Hello Divyesh Chapaneri,

Thank you for the question.

You can use the ItemDataBound event for your scenario. Although the linked help article is in the RadComboBox section, it is also valid for RadListBox. The code snippet in your case will be similar to the shown below:
public Form1()  
{  
    InitializeComponent();  
 
    this.radListBox1.ItemDataBound += new Telerik.WinControls.UI.ItemDataBoundEventHandler(radListBox1_ItemDataBound);  
    this.radListBox1.DataSource = this.customersBindingSource;  
    this.radListBox1.DisplayMember = "ContactName";  
    this.radListBox1.ValueMember = "CustomerID";  
}  
 
private void Form1_Load(object sender, EventArgs e)  
{  
    // TODO: This line of code loads data into the 'nwindDataSet.Customers' table. You can move, or remove it, as needed.  
    this.customersTableAdapter.Fill(this.nwindDataSet.Customers);  
}  
 
void radListBox1_ItemDataBound(object sender, Telerik.WinControls.UI.ItemDataBoundEventArgs e)  
{  
    RadListBoxItem item = e.DataBoundItem as RadListBoxItem;  
    item.DescriptionText = ((DataRowView)e.DataItem).Row["ContactTitle"].ToString();  

If you have additional questions, feel free to contact me.

All the best,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Gourangi
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or