Exemple #1
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int index = Convert.ToInt32(e.CommandArgument);
            int id    = Convert.ToInt32(GridView1.DataKeys[index]["Id"].ToString());

            if (e.CommandName == "Up")
            {
                int previous_id = Convert.ToInt32(GridView1.DataKeys[index - 1]["Id"].ToString());
                int option      = 1;
                banner_obj.UpdateSortKey(option, id, previous_id);
            }
            if (e.CommandName == "Down")
            {
                int previous_id = Convert.ToInt32(GridView1.DataKeys[index + 1]["Id"].ToString());
                int option      = 0;
                banner_obj.UpdateSortKey(option, id, previous_id);
            }
            FillDataInGrid();

            //int index = Convert.ToInt32(e.CommandArgument);
            //GridViewRow gvrow = GridView1.Rows[index];
            //GridViewRow previousRow;

            //if (e.CommandName == "Up")
            //{
            //    previousRow = GridView1.Rows[index - 1];
            //    int current_sortkey = Convert.ToInt32(GridView1.DataKeys[gvrow.RowIndex].Value.ToString());
            //    int id = Convert.ToInt32(gvrow.Cells[0].Text);
            //    int previous_id = Convert.ToInt32(previousRow.Cells[0].Text);
            //    int option=1;
            //    banner_obj.UpdateSortKey(option, id, previous_id, current_sortkey);
            //}
            //if (e.CommandName == "Down")
            //{
            //    previousRow = GridView1.Rows[index + 1];
            //    int current_sortkey = Convert.ToInt32(GridView1.DataKeys[gvrow.RowIndex].Value.ToString());
            //    int id = Convert.ToInt32(gvrow.Cells[0].Text);
            //    int previous_id = Convert.ToInt32(previousRow.Cells[0].Text);
            //    int option = 1;
            //    banner_obj.UpdateSortKey(option, id, previous_id, current_sortkey);
            //}
            //FillDataInGrid();
        }