Blog Of Sem: Aspxgridview selected ve toplu işlemleri

Aspxgridview selected ve toplu işlemleri

--aşağıdaki kod bütün seçili rowlara işlem yapar
            List<object> SelectedUsers = grid.GetSelectedFieldValues(new string[] { "ID", "TUTAR" });
            foreach (object user in SelectedUsers)
            {
                IList items = user as IList;
                if (items == null) return;
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CarringtonWebConnectionString1"].ConnectionString);
                con.Open();
                SqlCommand cmd = new SqlCommand("update ACIKHESAP set ODEME_DURUMU=1, ODENEN_TUTAR=" + items[1].ToString() + " where ID=" + items[0].ToString(), con);
                cmd.ExecuteNonQuery();
            }


---aşağıdaki kod seçili seçili deil farketmez hepsine işlem yapar
            for (int i = 0; i < grid.VisibleRowCount; i++)
            {
                var items = grid.GetRowValues(i, new string[] { "ID", "TUTAR" }) as object[];
                // ASPxListBox1.Items.Add(rowValues[0].ToString());
                //you can add these key in a list here

                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CarringtonWebConnectionString1"].ConnectionString);
                con.Open();
                SqlCommand cmd = new SqlCommand("update ACIKHESAP set ODEME_DURUMU=2, ODENEN_TUTAR=" + items[1].ToString() + " where ID=" + items[0].ToString(), con);
                cmd.ExecuteNonQuery();