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

Lookup columns

0 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 04 Aug 2011, 03:48 PM
Hello,
I have a table colulmn which contains some IDs. And I have a List<something> which contains reference values for those IDs. Is there a simple way to display those values in the grid column?
It's not possible to use data relations and so on, and the only way to get data is the way described above. And it's not possible to use a ComboBox to display data. I tried to create a template column and put the label there but this would take very much time when combination of large lists and tables is used. Is there a way to do that faster?

Here is what I do in template:
public override void InstantiateIn(Control container)
        {
            Label lbl = new Label();
            lbl.DataBinding += label_DataBinding;
            container.Controls.Add(lbl);
}        
 
        void label_DataBinding(object sender, System.EventArgs e)
        {
            Label lbl = (Label)sender; 
            GridDataItem dataItem = lbl.NamingContainer as GridDataItem;
            DataRowView drv = (DataRowView)dataItem.DataItem;
            RefItem item = Item.refdef.ItemsFlat.Find(m => m.Id == drv[Item.user_name].ToGuid());
            if (item == null)
            {
                lbl.Text = "";
                return;
            }
            lbl.Text = item.Caption;
        }

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Dmitry
Top achievements
Rank 1
Share this question
or