protected void btnExport_Click(object sender, ImageClickEventArgs e)
    {
        int rowcount = ucCustomPagerItems.isCountRecord;

        string vesselcode = (ViewState["VesselCode"] == null) ? null : (ViewState["VesselCode"].ToString());

        int?deptcode = null; if (DDLOfficeDept.SelectedValue != "0")
        {
            deptcode = Int32.Parse(DDLOfficeDept.SelectedValue);
        }
        int?year = null; if (ddlYear.SelectedValue != "0")
        {
            year = Int32.Parse(ddlYear.SelectedValue.ToString());
        }
        int?month = null; if (ddlMonth.SelectedValue != "0")
        {
            month = Int32.Parse(ddlMonth.SelectedValue.ToString());
        }


        int?assigndeptstatus = null; if (optAssignDept.SelectedValue != "2")
        {
            assigndeptstatus = Int32.Parse(optAssignDept.SelectedValue);
        }
        int?smsnextreview = null; if (optSMSReview.SelectedValue != "2")
        {
            smsnextreview = Int32.Parse(optSMSReview.SelectedValue);
        }
        string sortbycoloumn = (ViewState["SORTBYCOLOUMN"] == null) ? null : (ViewState["SORTBYCOLOUMN"].ToString());
        int?   sortdirection = null; if (ViewState["SORTDIRECTION"] != null)
        {
            sortdirection = Int32.Parse(ViewState["SORTDIRECTION"].ToString());
        }



        DataSet ds = BLL_SCM_Report.SCMReportIssueAssignmentSearch(UDFLib.ConvertIntegerToNull(DDLFleet.SelectedValue), UDFLib.ConvertIntegerToNull(vesselcode)
                                                                   , null, deptcode, year, month, txtSearchBy.Text.Trim(), assigndeptstatus, smsnextreview
                                                                   , sortbycoloumn, sortdirection, null, null, ref rowcount);


        string[] HeaderCaptions  = { "Vessel", "Month", "Year", "Assign Dept.", "SCM Tab", "Vessel Issue", "Created By", "SMS Review" };
        string[] DataColumnsName = { "Vessel_Name", "Month", "Year", "Department", "TAB_NAME", "VESSEL_ISSUE", "Issue_Created_By", "SMS_NEXT_REVIEW" };

        GridViewExportUtil.ShowExcel(ds.Tables[0], HeaderCaptions, DataColumnsName, "Vessel Issue Assignment", "Vessel Issue Assignment", HtmlFilterTable());
    }
    public void BindSCMIssueAssignmentSearch()
    {
        int rowcount = ucCustomPagerItems.isCountRecord;

        string vesselcode = (ViewState["VesselCode"] == null) ? null : (ViewState["VesselCode"].ToString());

        int?deptcode = null; if (DDLOfficeDept.SelectedValue != "0")
        {
            deptcode = Int32.Parse(DDLOfficeDept.SelectedValue);
        }
        int?year = null; if (ddlYear.SelectedValue != "0")
        {
            year = Int32.Parse(ddlYear.SelectedValue.ToString());
        }
        int?month = null; if (ddlMonth.SelectedValue != "0")
        {
            month = Int32.Parse(ddlMonth.SelectedValue.ToString());
        }


        int?assigndeptstatus = null; if (optAssignDept.SelectedValue != "2")
        {
            assigndeptstatus = Int32.Parse(optAssignDept.SelectedValue);
        }
        int?smsnextreview = null; if (optSMSReview.SelectedValue != "2")
        {
            smsnextreview = Int32.Parse(optSMSReview.SelectedValue);
        }
        string sortbycoloumn = (ViewState["SORTBYCOLOUMN"] == null) ? null : (ViewState["SORTBYCOLOUMN"].ToString());
        int?   sortdirection = null; if (ViewState["SORTDIRECTION"] != null)
        {
            sortdirection = Int32.Parse(ViewState["SORTDIRECTION"].ToString());
        }


        DataSet ds = BLL_SCM_Report.SCMReportIssueAssignmentSearch(UDFLib.ConvertIntegerToNull(DDLFleet.SelectedValue), UDFLib.ConvertIntegerToNull(vesselcode)
                                                                   , null, deptcode, year, month, txtSearchBy.Text.Trim(), assigndeptstatus, smsnextreview
                                                                   , sortbycoloumn, sortdirection, ucCustomPagerItems.CurrentPageIndex, ucCustomPagerItems.PageSize, ref rowcount);


        if (ucCustomPagerItems.isCountRecord == 1)
        {
            ucCustomPagerItems.CountTotalRec = rowcount.ToString();
            ucCustomPagerItems.BuildPager();
        }

        if (ds.Tables[0].Rows.Count > 0)
        {
            gvIssueAssign.DataSource = ds.Tables[0];
            gvIssueAssign.DataBind();

            if (ViewState["ID"] == null)
            {
                ViewState["ID"] = ds.Tables[0].Rows[0]["ResponseID"].ToString();
                //gvIssueAssign.SelectedIndex = 0;
            }

            // SetRowSelection();
        }
        else
        {
            gvIssueAssign.DataSource = ds.Tables[0];
            gvIssueAssign.DataBind();
        }
    }