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

How to Get/Set value in ComboBox in GridView column

4 Answers 274 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Virendra
Top achievements
Rank 1
Virendra asked on 27 Apr 2009, 06:02 AM
Hi,

I have GridView, with combobox type column. 
and have buttun outside of gridview,

now on click of buttuon
1) GET the selected value of the combobox in the selected row
2) SET the selected value in the combobox to the (selectedRowIndex+selectedColumnIndex) 

How can i do this?

thanks
virendra

4 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 29 Apr 2009, 12:05 PM
Hi Virendra,

Typically the ComboBox in the GridViewCombobox column reacts to changes of the value of the cell. When shown (e.g. when the cell swtitches to edit mode ) the ComboBox will respect the value of the cell and display the right item .

So  the straight-forward approach would  to get and set the value fof the cell.

Here is some code that displays the value of a cell in the current row (Provided that we need the value of the first cell) :
            GridViewRow currentRow = this.RadGridView1.ItemsControl.ItemsGenerator.ContainerFromItem(this.RadGridView1.CurrentRecord) as GridViewRow;  
            GridViewCell cell = currentRow.Cells[0] as GridViewCell;  
            MessageBox.Show(cell.Value.ToString()); 

Note that the cell value is commited after cell editing is finished and focus is moved to another cell.
If that does not fit your scenario , please give me more details on your requirements , so I can prepare a sample app for you.

All the best,
Pavel Pavlov
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.
0
Brad
Top achievements
Rank 2
answered on 16 Mar 2010, 10:04 PM
How do I set the selected value of a combobox in javascript.

I click on a line in a RadGrid.
In a combobox INSIDE an EditItemTemplate in a form view ("TE") I want to have the value selected and visible.

I have the value from the grid, I can get to the combobox with:

var CliCB = $find('<%= TE.FindControl("ClientCB").ClientID %>');

I know the value is IN the combobox


CliCB.findItemByValue(CID);

CliCB.select();


doesn't work


CliCB.SelectedValue= CID;


doesn't work


HOW is this done????


Thanks,


Joe B

0
Vlad
Telerik team
answered on 17 Mar 2010, 07:26 AM
Hello Joe,

I believe that your question should be posted in our ASP.NET AJAX forums.

All the best,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Veda
Top achievements
Rank 1
answered on 14 Jun 2011, 06:43 AM
Hi,
How to get and set the value of rabcombobox which is in a column of rad grid view using MVVM model for silverlight.
Tags
GridView
Asked by
Virendra
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Brad
Top achievements
Rank 2
Vlad
Telerik team
Veda
Top achievements
Rank 1
Share this question
or