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

[Solved] Grid - Get Column ID of each row

1 Answer 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kiang
Top achievements
Rank 1
Kiang asked on 18 May 2012, 10:37 AM
hello , someone can teach me how to get ID of each row in telerik grid view?

This is my code
@(Html.Telerik().Grid((IEnumerable<companytable>)ViewData["CompanyId"])
                    .DataKeys(key => key.Add(o => o.ID))
                    .DataBinding(bind => bind.Server().Select("Create", "table1"))
                    .Name("Unit").Columns(columns =>
                    {
                        columns.Bound(o => o.ID);
                        columns.Bound(o => o.CompanyName);
                    })
                    .Selectable()
                    .Pageable()
                    .Filterable()
                    .Sortable()
                    .RowAction(row =>
                        {
                            row.Selected = row.DataItem.ID.Equals(ViewData["Company"]);
                        })
                    .PrefixUrlParameters(false))

1 Answer, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 23 May 2012, 09:27 AM
Hi,

I am not sure if I understand the question. The rows don't have unique identifiers and the record ID can be found in the RowAction through the DataItem property. From where do you want to get the ID and how do you want to use it?

All the best,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Grid
Asked by
Kiang
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or