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
205
Wow! LQQK Here (Video included) - Serious Issue With Moving Rows Up and Down. We're stumped!!!
posted

Having an issue with the rowID never changing after initial click with following code:

(I have also attached a copy of the page)

Also, what is the equivalent for DataGrid1.SelectedIndex = iRank2;

*********************************************************

protected void xlGrid_ItemCommand(object sender, Infragistics.WebUI.UltraWebGrid.UltraWebGridCommandEventArgs e)
        {
            Int32 rowID = 0;
            DataRow dr1 = null;
            DataRow dr2 = null;
            Int32 iRank1 = 0;
            Int32 iRank2 = 0;
            Int32 iRank = 0;

            // convert the ParentControl to a CellItem object
            Infragistics.WebUI.UltraWebGrid.CellItem ci = e.ParentControl as
                Infragistics.WebUI.UltraWebGrid.CellItem;

            if (ci != null)
            {
                // From the CellItem object, get the Row object
                Infragistics.WebUI.UltraWebGrid.UltraGridRow row = ci.Cell.Row;
                rowID = (Int32)row.Cells.FromKey("ActivityID").Value; <=PROBLEM AREA
                DataView dv = new DataView(dt, null, "Sequence", DataViewRowState.CurrentRows);
              

                for (Int16 i = 0; i < dv.Count; i++)
                {
                    if (dv[i]["ActivityID"].Equals(rowID))
                    {
                        iRank = Convert.ToInt32(dv[i]["Sequence"]);

                        switch(e.InnerCommandEventArgs.CommandName.ToString())
                        {
                            case "MoveUp":
                                if (i > 0)
                                {
                                    //we cannot change the rank values otherwise the
                                    //the order of the rows in the DataView would
                                    //change because the DataView is sorted Rank
                                    //so we save those values till the end of the loop
                                    dr1 = dv[i].Row;
                                    dr2 = dv[i - 1].Row;
                                    iRank1 = (Int32)dv[i]["Sequence"];
                                    iRank2 = (Int32)dv[i - 1]["Sequence"];

                                }
                                break;
                            case "MoveDown":
                                if (i < dv.Count - 1)
                                {
                                    dr1 = dv[i].Row;
                                    dr2 = dv[i + 1].Row;
                                    iRank1 = (Int32)dv[i]["Sequence"];
                                    iRank2 = (Int32)dv[i + 1]["Sequence"];

                                    dr1[

"Sequence"] = iRank2;

                                    dr2[

"Sequence"] = iRank1;

                                   dt.AcceptChanges();

 

 

                                }
                                break;
                        }
                    }
                }
                if (dr1 != null && dr2 != null)
                {
                    dr1["Sequence"] = iRank2;
                    dr2["Sequence"] = iRank1;
                    //DataGrid1.SelectedIndex = iRank2;
                    //xlGrid.selectedIndex = iRank2;
                }
                Session["FilesOrder"] = dt;
            }
        }

                                }
                                break;
                        }
                    }
                }
                if (dr1 != null && dr2 != null)
                {
                    dr1["Sequence"] = iRank2;
                    dr2["Sequence"] = iRank1;
                    //DataGrid1.SelectedIndex = iRank2;
                    //xlGrid.selectedIndex = iRank2;
                }
                Session["FilesOrder"] = dt;
            }
        }

 

 

 So basically, if we click the up arrow it will move the row up and rebind - so far, so good.  Now when we click that same row, it will more the row above it up instead of the row we click. 

Infragistics.WebUI.UltraWebGrid.UltraGridRow row = ci.Cell.Row;

In the event handler, this is getting populated with the same row even though we moved that row up!  It's very bizarre. 

Here's a video to show you the behavior.  Note that row with Id 87 constantly moves up although we're not clicking that row...