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

GridViewComboBoxColumn (RadGridview for Winforms)

1 Answer 168 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shridhar
Top achievements
Rank 1
Shridhar asked on 11 Jul 2012, 01:11 PM
Hi,

I am using the "GridViewComboBoxColumn" in the radgrid win forms. I have created a type of GridViewComboBoxColumn and added it to radgridview.

            gridViewDDLCombbxColumn2.FieldName = "Data Base No";
            gridViewDDLCombbxColumn2.Name = "DataBaseNoCombo";
            gridViewDDLCombbxColumn2.HeaderText = "Data Base Num";
            gridViewDDLCombbxColumn2.DataSource = GetUserGrpData;
            gridViewDDLCombbxColumn2.DisplayMember = "DBNumber";
            gridViewDDLCombbxColumn2.ValueMember = "UserGroupID";
            this.radGridViewUserGroup.MasterTemplate.Columns.Add(gridViewDDLCombbxColumn2);

I am facing an issue when setting a default value or value from database to GridViewComboBoxColumn and while updating also I am not able to read the selected value from the GridViewComboBoxColumn.

For E.G:
this.radDdlDn.SelectedValue = currentRow.Cells["UserID"].Value;
The above statement can be used to assign the value to radDropdownlist.

String strddlValue=this.radDdlDn.selectedItem.Text
The above statement can be used to read the selected value from radDropdownlist.

Similarly how can we  perform the same operation with GridViewComboBoxColumn in radGridview

Thanks in advance
Shiva



1 Answer, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 13 Jul 2012, 01:58 PM
Hello Shiva,

Thank you for writing.

I am not sure I understand your question completely, but I will try to give you some general information on setting and retrieving the value of a cell and the text displayed.

To get the value of a cell in a GridViewComboBoxColumn, you should use the following regardless of the column type:
object value = this.radGridView1.Rows[indexOfDesiredRow].Cells["Name of column"].Value;

To get the text that is displayed for that value you can use the following:
GridViewComboBoxColumn comboBoxColumn = this.radGridView1.Columns["column"];
string text = comboBoxColumn.GetLookupValue(this.radGridView1.Rows[indexOfDesiredRow].Cells["column"].Value);

If this is not what you were asking for, I would kindly ask you to send some more details on your case. If you describe the whole scenario you want to implement, I will be able to better understand what you need and give you an adequate response.

I am looking forward to your reply.

All the best,
Ivan Petrov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Shridhar
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or