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

Get value of row in the Item_Createt Event

1 Answer 13 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nileshkumar
Top achievements
Rank 1
Nileshkumar asked on 17 Jul 2013, 09:51 AM
Hi,

I want to get value of each row in the RadGrid_ItemCreated Event. How to get Values of each row in this event?

Note: I don't want to use RadGrid_ItemDataBound event.

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 17 Jul 2013, 10:16 AM
Hello,

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"
        OnNeedDataSource="RadGrid1_NeedDataSource" onitemcreated="RadGrid1_ItemCreated">
        <MasterTableView DataKeyNames="ID">
            <Columns>
                <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    dynamic data = new[] {
        new { ID = 1, Name = "Name1"},
        new { ID = 2, Name = "Name2"},
        new { ID = 3, Name = "Name3"},
        new { ID = 4, Name = "Name4"},
        new { ID = 5, Name = "Name5"}
    };
 
    RadGrid1.DataSource = data;
}
 
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;
        string strID = item.GetDataKeyValue("ID").ToString();
    }
}

Please try with the Datakey. We will not access the Data bceuase still data is not assigned to the grid.

http://www.telerik.com/help/aspnet-ajax/events_t_telerik_web_ui_radgrid.html
http://www.telerik.com/help/aspnet-ajax/grid-event-sequence.html

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Nileshkumar
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or