Hello guys sorry if this question was posted many times but i searched and so far no answer satisfactory enough.I a bit new to infragistics.I'm using the version .NETAdvantage 2007 vol 2 CLR 2.0 and this is my first project.
here is my problem.
I've tried using the ultragrid with an objectdatasource or a webservicedatasource collecting an array of an object and it's works very well.so to access an activerow data i use
private void utAllUsers_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { try { selected = (IUser)utAllUsers.DisplayLayout.ActiveRow.ListObject; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
Now the problem is that i've created a simple table (Id | Name | Description) with primary key Id (identity)
i bind the grid to a datatable and when i try to access the id of the active row, it Gives me Compleley other ids and i don't get it at all
here are codes
private void utgrRights_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { UltraGridRow rightrow; rightrow = utgrRights.Rows[utgrRights.DisplayLayout.ActiveRow.ListIndex]; rightid = (int)rightrow.Cells[0].Value; Name = rightrow.Cells[1].Value.ToString(); }
How do i get the correct Id no matter how Sorted is the table? Thanks for reading this!!
I also think you need the ActiveRow, but I don't understand why you need the row index. Any row has a property named Index, but if you need any cell value you can use row.GetCellValue(column).
Thanks for reading and for replying.I think what i want is activerow since i want to edit it by giving it the focus.There is a second aspect of the question i'll like some few help.Supposing i use the selected property that you suggested ,how do i know the exact index of the row which is selected in order to get that UltraGridRow t o extract it value since i don't use object this time?Thanks again
You're confusing active and selected row. Active row is the row that has the focus, hence there is only one active row. Any row can be selected and there can be more than one.
If you want to get the active row when it is changed, use AfterRowActivate and get its object by grid.ActiveRow.ListObject
If you want the selected row(s) use grid.Selected.Rows[]