Ejemplo n.º 1
0
        protected void grd_RowCommand(object sender, GridViewCommandEventArgs e)//Row command function for grid functionality
        {
            int    rowIndex = Convert.ToInt32(e.CommandArgument.ToString());
            string batchid  = this.grd.DataKeys[rowIndex]["ID"].ToString();

            if (e.CommandName == "updates")
            {
                ListToDataTable lsttodt = new ListToDataTable();
                var             lst     = _service.GetBatchDataByID(Guid.Parse(batchid));
                DataTable       dt      = lsttodt.ToDataTable(lst);
                if (dt != null && dt.Rows.Count > 0)
                {
                    hdnbatchid.Value       = dt.Rows[0]["ID"].ToString();
                    txtBatchName.Text      = dt.Rows[0]["BatchName"].ToString();
                    txtBatchCode.Text      = dt.Rows[0]["BatchCode"].ToString();
                    txtAssessmentDate.Text = dt.Rows[0]["AssessmentDate"].ToString();
                    txtCourse.Text         = dt.Rows[0]["Course"].ToString();
                    txtLanguage.Text       = dt.Rows[0]["Language"].ToString();
                    txtNoOfCandidates.Text = dt.Rows[0]["NoOfCandidate"].ToString();
                    btnSubmit.Text         = "Update";
                }
                else
                {
                    //do nothing
                    btnSubmit.Text = "Save";
                }
            }
            else
            {
                DataTable dt     = new DataTable();
                bool      result = _service.DeletesBatchData(Guid.Parse(batchid));
                if (result)
                {
                    bindGrid();
                }
            }
        }