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

GridViewComboBoxColumn Tag attribute

1 Answer 93 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 17 Aug 2011, 06:00 AM
(C#)
When using a GridViewComboBoxColumn is it possible to set the Tag attribute on the cell item who's value comes from the grid combo box.

So I can call:
gridView1.CurrentRow.Cells["ColumnName"].Tag

I understand this would probably have something to do with the GridViewComboBoxColumn DataSource and what it is passed.

For Example
I have two GridViewComboBoxColumns in my GridView, call them "suppliers" and "products".
These items get populated from a database where each has a GUID and a Name.
I would like the Name to show in the grid combobox item for each column and the GUID to be assigned to the grid combo box item tag (or some other place).
When the user changes the "supplier" in any row, I would like to fetch the list of products from the database by searching for the supplier GUID.
Currently it seems all I can get back is the string name. I can see the gridView1.CurrentRow.Cells["ColumnName"].Tag however it is null

Any help would be appreciated, and if you need more info or something to be clearer please ask.

Thanks In advance
Tom.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 17 Aug 2011, 01:39 PM
Hi Tom,

Thank you for writing.

Let's look into the concrete scenario which you have described. You can achieve the desired behavior by binding the GridViewComboBoxColumn and specify as a DisplayMember the name field - in order to display the name, and as ValueMember the GUID field - which will allow you to access the GUID from the cell Value property. More information regarding binding GridViewComboBoxColumn can be found in this help article.

I hope that you find this information helpful. If you have additional questions, feel free to write back.

Kind regards,
Stefan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
GridView
Asked by
Tom
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or