currentrowchanging

3 posts, 0 answers
  1. Adi
    Adi avatar
    2 posts
    Member since:
    Oct 2015

    Posted 26 Oct 2015 Link to this post

    I have problem when using currentrowchanging event,

     when first load the grid, when I change the row,, the event fire correctly, this is my event,

    buf after sorting or grouping it appear not correct.....

    this is the condition

    1.  when I click the row in index 4  (ID = ROM and name = ROMA VATIKAN), buf after sorting the column country name, when I click the index   4  (ID = ​ALS and name = ALASKA),  the value is still (ID = ROM and name = ROMA VATIKAN) not  (ID = ​ALS and name = ALASKA)... how to get value ID = "ALS" in index for,, look for the attachment image (grid after order by.png)

    2. when I click the row in index 1  (ID = ​BGR and name = ​BOGOR), buf after grouping the column country name, when I click the value  (ID = ​​ROM and name = ​ROMA VATIKAN),  the value is still (ID = ​BGR and name = ​BOGOR) not  (ID = ROM and name = ROM VATIKAN) cause it refer into index = 1... how to get value ID = "ROM" in index for,, look for the attachment image (grid after grouping.png)

    this is my currenrowchanging event

      void gridData_CurrentRowChanging(object sender, CurrentRowChangingEventArgs e)
            {
                if (gridData.RowCount != 0)
                {
                    int rowindex = 0;

                    if (e.NewRow == null)
                    {
                        ClearData();
                        return;
                    }

                    rowindex = e.NewRow.Index;
                    //}

                    txtID.Text = gridData.Rows[rowindex].Cells["ID"].Value.ToString();
                    txtName.Text = gridData.Rows[rowindex].Cells["Name"].Value.ToString();
                    cmbCountryID.Text = gridData.Rows[rowindex].Cells["CountryID"].Value.ToString();
                    cmbCountryName.Text = gridData.Rows[rowindex].Cells["CountryName"].Value.ToString();

                    if (gridData.Rows[rowindex].Cells["ActiveStatus"].Value.ToString() == "1")
                    {
                        rbYes.IsChecked = true;
                    }
                    else
                    {
                        rbNo.IsChecked = true;
                    }
                }
            }

     


     
     
     
     
     
     
     
     
     
  2. Dimitar
    Admin
    Dimitar avatar
    1411 posts

    Posted 26 Oct 2015 Link to this post

    Hello Adi,

    Thank you for writing.

    It would be better to retrieve the value without using the index:
    void radGridView1_CurrentRowChanging(object sender, Telerik.WinControls.UI.CurrentRowChangingEventArgs e)
    {
        if (radGridView1.RowCount != 0)
        {
            if (e.NewRow == null)
            {
                 ClearData();
                return;
            }
            
            var newCurrentRow = e.NewRow;
     
            string name = newCurrentRow.Cells["Name"].Value.ToString();
             
        }
    }

    The following article explains why the index is different: Rows vs ChildRows.

    I hope this helps.

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Adi
    Adi avatar
    2 posts
    Member since:
    Oct 2015

    Posted 26 Oct 2015 Link to this post

    thanks dimitar it solve my problems
Back to Top