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

Is there a way to know column index of GridDataItem in GridItemDataBound Event?

2 Answers 365 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Robin
Top achievements
Rank 2
Robin asked on 10 Apr 2014, 06:05 AM
Hello, 

I would like to access grid column header from grid item databound event. Purpose is to validate data and display error message together with column header text. Please see following sample code. Is there a way to know column header or column index from GridDataItem?

 protected void gridSample_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem _item = e.Item as GridDataItem;
                if (_item["unique_name"].Text == "something") //condition
                {
                    string l_columnHeader = gridSample.Columns[_item - column - index].HeaderText; //<-- Required column header text

                    DisplayErrorMsg("Error at column:" + l_columnHeader);
                }
            }
        }


Thanks in advanced,
Robin




2 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 15 Apr 2014, 02:16 AM
Hello Robin,

I think that the Accessing Cells Using Column Unique Name section in the following article will help you achieve your goal:
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Pavlina
Telerik team
answered on 15 Apr 2014, 02:18 AM
Hi Robin,

I think that the Accessing Cells Using Column Unique Name section in the following article will help you achieve your goal:
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Robin
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Share this question
or