We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to access column of a grid by its bound field?

How can I access a column of a bound grid by the field? If I have bound a grid by a table "Projects", and I want to read the data of ProjectId or any other column by Field name; upon double click event of the row; then I should be able to read the data of that column. Somthing like that syncFindGrid.Columns("ProjectId").text syncFindGrid.Columns("LocationId").text etc I don''t want to use (Colindex,Rowindex).text methos because I am not sure of the index of the columns, since I am filling it for different fomrs with different tables.

1 Reply

AD Administrator Syncfusion Team January 16, 2006 11:40 AM UTC

Hi Abdul, To access a column value based on its fieldname or column name, make use of the NameToColIndex property of the grid. Inserting the following code in the CellDoubleClick Event of the grid achieves the same. int colInd = this.gridDataBoundGrid1.Binder.NameToColIndex("Col1"); // specify the column name here MessageBox.Show(this.gridDataBoundGrid1.Model[e.RowIndex,colInd].CellValue.ToString()); On double clicking any row you can view that particular column value. Please refer the sample attached for demonstration of these functionalities. Thanks, Rajagopal

ColAccessSample.zip

Loader.
Live Chat Icon For mobile
Up arrow icon