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

SelectedIndexChanged in GridViewComboBoxColumn

1 Answer 402 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sheraz Naseeb
Top achievements
Rank 1
Sheraz Naseeb asked on 13 Aug 2010, 11:37 AM
Hi Telerik Team,

I am struggeling with an issue, Actually I have a GridView in wich I have 5 different columns. One of these columns is a GridViewComboBoxColumn. My issue is I need to get the selected value of this combobox and set that value into the next column.

Is that possible to handle SelectedIndexChanged event of GridViewComboBoxColumn and also can we handle ItemDataBound event of GridViewComboBoxColumn.

Please help,

Many thanks

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 18 Aug 2010, 05:21 PM
Hi Sheraz,

Thank you for writing.

In case you are using RadControls version 2009.1.414 as you pointed out in your support ticket info, the best approach to achieve the desired behavior is by subscribing for the CellEndEdit event. Please refer to the following code snippet:

void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
    int destinationColumnIndex = e.ColumnIndex + 1;
    radGridView1.Rows[e.RowIndex].Cells[destinationColumnIndex].Value = radGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
}

Private Sub radGridView1_CellEndEdit(sender As Object, e As GridViewCellEventArgs)
    Dim destinationColumnIndex As Integer = e.ColumnIndex + 1
    radGridView1.Rows(e.RowIndex).Cells(destinationColumnIndex).Value = radGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
End Sub

On the other hand, I saw that you have downloaded also version 2010.2.10.713, and since we have made many improvements in our GridView since Q1 2009 the approach is different. Here is a snippet:

void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e)
{
   if (e.Column is GridViewComboBoxColumn)
   {
       radGridView1.Rows[e.RowIndex].Cells["DestinationColumnName"].Value = e.Value;
   }
}

Private Sub radGridView1_CellValueChanged(sender As Object, e As GridViewCellEventArgs)
    If TypeOf e.Column Is GridViewComboBoxColumn Then
        radGridView1.Rows(e.RowIndex).Cells("DestinationColumnName").Value = e.Value
    End If
End Sub

If you are using the old version of our controls, I highly recommend you to upgrade to the latest version, since many improvements and new features were added, and the whole control API was changed. Detailed information regarding the introduced changes of each release can be found in our Release Notes.

I hope you find this information helpful. In case you need any additional assistance, do not hesitate to contact us.

Sincerely yours,
Stefan
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
Tags
GridView
Asked by
Sheraz Naseeb
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or