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

Getting a value from GridViewLookupColumn

3 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
BILLY ALLEN
Top achievements
Rank 1
BILLY ALLEN asked on 18 Dec 2008, 09:19 PM
I have the following:
 

GridViewLookUpColumn 

 

cs = 
    (
GridViewLookUpColumn) grdDocActivities.Columns.FindByUniqueName("colSubDisc");

Question:

How can I get the current selected value of this control?

I see there's a "GetLookupValue()" method, but I can't find details on how to use it.

Advice or tips?  Thanks!

 

 

 

 

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 20 Dec 2008, 12:00 PM
Hello BILLY ALLEN,

Thank you for contacting us.

You can find the corresponding DisplayMember from the known cell value by using the GetLookupValue method. Please, review the code below as example:
 
object displayMember = ((GridViewComboBoxColumn)radGridView1.Columns[2]).GetLookupValue(value); 

If you have a different scenario, please send me more details on your requirements. This will help me to understand your case and provide you with further assistance.
 

Regards,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
BILLY ALLEN
Top achievements
Rank 1
answered on 22 Dec 2008, 02:10 PM
Thanks Martin,

Not quite there yet.  I'll explain further:

I am doing in-grid editing.  A few of the columns are drop-down lists.  The twist is that the drop-down lists are related to each other -- that is, the second one depends on the first one, and so on (e.g., cascading drop downs).

I think the CellBeginEdit event is where I need to do all the work (if not, please point the way!). 

So, in this event, how can I get the currently-selected value of a drop-down list that's selected in the grid? 

Here's some stuff that I've been doing so far:

// doc activities row editing, entering a cell

 

GridViewColumn col = grdDocActivities.Columns[e.ColumnIndex];

 

 

if (col is GridViewLookUpColumn)

 

{

 

    int subDisc = 0;

 

 

    GridViewLookUpColumn cs = (GridViewLookUpColumn)grdDocActivities.Columns.FindByUniqueName("colSubDisc");
    // so now I have this column.  How can I get its selected value?

 

}

thanks for your time and consideration.

 

0
Martin Vasilev
Telerik team
answered on 23 Dec 2008, 10:25 AM
Hi BILLY ALLEN,

Thank you for getting back to me.

In CellBeginEdit event you can access value and text from any combo box cell element using a code like the following:
void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)  
{  
    if (this.radGridView1.CurrentRow == this.radGridView1.MasterGridViewInfo.TableAddNewRow)  
    {  
        object valueMember = ((GridComboBoxCellElement)this.radGridView1.MasterGridViewInfo.TableAddNewRow.Cells["colSubDisc"].CellElement).Value;  
        string displayMember = ((GridComboBoxCellElement)this.radGridView1.MasterGridViewInfo.TableAddNewRow.Cells["colSubDisc"].CellElement).Text;  
 
    }  

Hope this helps. If you have other questions, do not hesitate to contact me again.

Regards,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
BILLY ALLEN
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
BILLY ALLEN
Top achievements
Rank 1
Share this question
or