Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Confused about ultragird displaylayout listobject and listindex
posted

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!!

Parents
  • 17259
    Offline posted

    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[]

     

Reply Children