GridViewComboBoxColumn Tag attribute

2 posts, 0 answers
  1. Tom
    Tom avatar
    2 posts
    Member since:
    Mar 2011

    Posted 17 Aug 2011 Link to this post

    (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.
  2. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 17 Aug 2011 Link to this post

    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 >>

Back to Top