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

How to look at row data from Grid?

2 Answers 54 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Todd
Top achievements
Rank 1
Todd asked on 30 Oct 2010, 01:27 AM
I have a RadGrid with a single row per record.  I wish to take the selected ID and populate a second grid control with extended data.  How do I access the row data that is selected from code behind?

I have an event that triggers when the person pushes select:

protected

 

 

void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)

 

{
}

The problem is I don't know how to access say the column named "FirstName"?  All I want to do is Debug write the first name selected to the console but I can't seem to get access.  I've tried various GridDataItem calls and conversions from code I can find on the web but nothing I found shows a simple straightforward way to traverse the row data selected.

Any help would be appreciated. :)

2 Answers, 1 is accepted

Sort by
0
Todd
Top achievements
Rank 1
answered on 30 Oct 2010, 01:29 PM
This is for C# btw.
0
Shinu
Top achievements
Rank 2
answered on 01 Nov 2010, 10:32 AM
Hello,


Use the NamingCntainer property of the RadComboBox instance to get the GridDataItem. And use the "ColumnUniqueName" to access the cell value.

Code:
protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
    RadComboBox combo = (RadComboBox) o;
    GridDataItem item = (GridDataItem) combo.NamingContainer;
    string value = item["FirstName"].Text;
}

My aspx is shown below.
<Columns>
    <telerik:GridTemplateColumn>
        <ItemTemplate>
            <telerik:RadComboBox AutoPostBack="true" ID="RadComboBox1" runat="server" Height="60px" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
                <Items>
                    <telerik:RadComboBoxItem Text="Selected 1" />
                    <telerik:RadComboBoxItem Text="Selected 2" />
                </Items>
            </telerik:RadComboBox>
        </ItemTemplate>
    </telerik:GridTemplateColumn>



-Shinu.
Tags
General Discussions
Asked by
Todd
Top achievements
Rank 1
Answers by
Todd
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or