protected void grTimeSheetApp_RowCommand(object sender, GridViewCommandEventArgs e) { GridView _gridView = (GridView)sender; // Get the selected index and the command name int _selectedIndex = int.Parse(e.CommandArgument.ToString()); string _commandName = e.CommandName; _gridView.SelectedIndex = _selectedIndex; //string strPreYrLv = ""; switch (_commandName) { case ("ApproveClick"): try { timeSheetMgr.UPDATE_TIMESHEET_STATUS(grTimeSheetApp.DataKeys[_gridView.SelectedIndex].Values[0].ToString(), ddlMonth.SelectedValue.ToString(), ddlYear.SelectedValue.ToString(), ddlFiscalYear.SelectedValue.ToString(), "A", Session["USERID"].ToString(), Common.SetDateTime(DateTime.Now.ToString())); timeSheetMgr.UPDATE_TIMESHEETLEAVE_STATUS(grTimeSheetApp.DataKeys[_gridView.SelectedIndex].Values[0].ToString(), ddlMonth.SelectedValue.ToString(), ddlYear.SelectedValue.ToString(), ddlFiscalYear.SelectedValue.ToString(), "A", Session["USERID"].ToString(), Common.SetDateTime(DateTime.Now.ToString())); } catch (Exception ex) { throw ex; } this.OpenRecord(); break; case ("ViewClick"): StringBuilder sb = new StringBuilder(); string strFromDate = ""; string strToDate = ""; lblMsg.Text = ""; string strURL = "TimeSheetReportPage.aspx?params=" + grTimeSheetApp.DataKeys[_gridView.SelectedIndex].Values[0].ToString() + "," + ddlMonth.SelectedValue.ToString() + "," + ddlYear.SelectedValue.ToString() + "," + ddlFiscalYear.SelectedValue.ToString(); //lblEmpName.Text.Trim() + "," + lblDesig.Text.Trim();// +"," + lblDept.Text.Trim() + "," + lblLoc.Text.Trim() + "," + lblOffice.Text.Trim(); sb.Append("<script>"); sb.Append("window.open('" + strURL + "', '', '');"); sb.Append("</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "ConfirmSubmit", sb.ToString(), false); ClientScript.RegisterStartupScript(this.GetType(), "ConfirmSubmit", sb.ToString()); break; case ("CancelClick"): break; } }