Example #1
0
 /// <summary>
 /// Delete the word
 /// </summary>
 private void BtnDelete()
 {
     if (!SpecificDictionaryWord.DeleteByKey(word, languageCode, SessionState.User.Id))
     {
         lbMessage.Text     = "Error: Word can't be deleted";
         lbMessage.CssClass = "hc_error";
         lbMessage.Visible  = true;
     }
     else
     {
         Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script>back();</script>");
     }
 }
Example #2
0
        /// <summary>
        /// Delete words selected
        /// </summary>
        private void DeleteSelectedItems()
        {
            lbMessage.Text = string.Empty;
            int nbDeletedRows  = 0;
            int nbSelectedRows = 0;

            foreach (Infragistics.WebUI.UltraWebGrid.UltraGridRow dr in dg.Rows)
            {
                TemplatedColumn col = (TemplatedColumn)dr.Cells.FromKey("Select").Column;
                CheckBox        cb  = (CheckBox)((CellItem)col.CellItems[dr.Index]).FindControl("g_sd");
                if (cb.Checked)
                {
                    nbSelectedRows++;
                    if (!SpecificDictionaryWord.DeleteByKey(dr.Cells.FromKey("word").ToString(), ViewState["LanguageCode"].ToString(), SessionState.User.Id))
                    {
                        lbMessage.Text     = "Error: word [" + dr.Cells.FromKey("word").ToString() + "] can't be deleted<br>";
                        lbMessage.CssClass = "hc_error";
                        lbMessage.Visible  = true;
                        break;
                    }
                    else
                    {
                        nbDeletedRows++;
                    }
                }
            }
            if (nbSelectedRows == 0)
            {
                lbMessage.Text     = "No words selected";
                lbMessage.CssClass = "hc_error";
                lbMessage.Visible  = true;
            }
            else
            {
                lbMessage.Text     = nbDeletedRows.ToString() + " words deleted";
                lbMessage.CssClass = "hc_success";
                lbMessage.Visible  = true;
                UpdateDataView();
                dg.DisplayLayout.Pager.CurrentPageIndex = 1;
            }
        }