Пример #1
0
 protected void ctlDelete_Click(object sender, ImageClickEventArgs e)
 {
     foreach (GridViewRow row in ctlStatusGrid.Rows)
     {
         if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked))
         {
             try
             {
                 short    id     = UIHelper.ParseShort(ctlStatusGrid.DataKeys[row.RowIndex].Value.ToString());
                 DbStatus status = DbStatusService.FindByIdentity(id);
                 DbStatusService.Delete(status);
             }
             catch (Exception ex)
             {
                 if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547)
                 {
                     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData",
                                                             "alert('This data is now in use.');", true);
                     ctlStatusGrid.DataCountAndBind();
                 }
             }
         }
     }
     StatusLangGridViewFinish();
     ctlStatusGrid.DataCountAndBind();
     ctlUpdatePanelGridView.Update();
 }
Пример #2
0
        protected void ctlStatusGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            short statusId;

            if (e.CommandName == "StatusEdit")
            {
                int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                statusId = Convert.ToInt16(ctlStatusGrid.DataKeys[rowIndex].Value.ToString());
                ctlStatusForm.PageIndex = (ctlStatusGrid.PageIndex * ctlStatusGrid.PageSize) + rowIndex;
                ctlStatusForm.ChangeMode(FormViewMode.Edit);
                IList <DbStatus> list = new List <DbStatus>();
                list.Add(DbStatusService.FindByIdentity(statusId));
                ctlStatusForm.DataSource = list;
                ctlStatusForm.DataBind();
                ctlUpdatePanelStatusForm.Update();
                ctlStatusGrid.DataCountAndBind();
                ctlStatusModalPopupExtender.Show();
            }
            if (e.CommandName == "Select")
            {
                int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                statusId = UIHelper.ParseShort(ctlStatusGrid.DataKeys[rowIndex].Value.ToString());
                ctlStatusLangGrid.DataSource = SsDbQueryProvider.DbStatusLangQuery.FindStatusLangByStatusId(statusId);
                ctlStatusLangGrid.DataBind();
                ctlSubmit.Visible = true;
                ctlFieldSetDetailGridView.Visible = true;
                ctlCancel.Visible = true;
                ctlStatusGrid.DataCountAndBind();
                ctlUpdatePanelStatusLangGridView.Update();
            }
        }