Example #1
0
    protected void grdSubCatRating_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DropDownList ddlRating = (e.Row.FindControl("ddlRating") as DropDownList);
                dsRating.Clear();
                dsRating                 = objInsp.GetRatings();
                ddlRating.DataSource     = dsRating.Tables[0];
                ddlRating.DataTextField  = "RatingValue";
                ddlRating.DataValueField = "Rating";
                ddlRating.DataBind();
                if ((e.Row.FindControl("hdnThisReport") as HiddenField).Value != "--SELECT--" && (e.Row.FindControl("hdnThisReport") as HiddenField).Value != "")
                {
                    decimal value   = Math.Round(UDFLib.ConvertToDecimal((e.Row.FindControl("hdnThisReport") as HiddenField).Value), 0);
                    string  FindVal = UDFLib.ConvertStringToNull(value);
                    if (ddlRating.Items.FindByText(FindVal) != null)
                    {
                        ddlRating.Items.FindByText(FindVal).Selected = true;
                    }
                }
                if ((e.Row.FindControl("hdnThisReport") as HiddenField).Value == "--SELECT--" || (e.Row.FindControl("hdnThisReport") as HiddenField).Value == "")
                {
                    // decimal value = Math.Round(UDFLib.ConvertToDecimal((e.Row.FindControl("hdnThisReport") as HiddenField).Value), 0);
                    //string FindVal = UDFLib.ConvertStringToNull(value) + ".00";
                    ddlRating.Items.FindByText("--SELECT--").Selected = true;
                }
                int JobCount = objInsp.INSP_Get_WorklistJobsCountByLocationID(Convert.ToInt32(ViewState["InspectionID"].ToString()), Convert.ToInt32((e.Row.Cells[1].FindControl("hdnSubCatCode") as HiddenField).Value));

                //(e.Row.Cells[8].FindControl("lblJobCount") as Label).Attributes.Add("data-badge",Convert.ToString(JobCount));
                (e.Row.Cells[8].FindControl("lnkAssignChecklist") as LinkButton).Attributes.Add("data-badge", Convert.ToString(JobCount));
            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[2].Text = dsSubCat.Tables[1].Rows[0][2].ToString();
                e.Row.Cells[3].Text = dsSubCat.Tables[1].Rows[0][3].ToString();
                e.Row.Cells[4].Text = dsSubCat.Tables[1].Rows[0][4].ToString();
                e.Row.Cells[5].Text = dsSubCat.Tables[1].Rows[0][5].ToString();
                e.Row.Cells[6].Text = dsSubCat.Tables[1].Rows[0][6].ToString();

                e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Left;
                e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Center;
                e.Row.Cells[4].HorizontalAlign = HorizontalAlign.Center;
                e.Row.Cells[5].HorizontalAlign = HorizontalAlign.Center;
                e.Row.Cells[6].HorizontalAlign = HorizontalAlign.Center;
            }



            if (e.Row.RowType == DataControlRowType.Header)
            {
                //  info1.AddMergedColumns(new int[] { 3, 4, 5, 6,7,8,9}, "Rating");
            }

            if (e.Row.RowType == DataControlRowType.EmptyDataRow)
            {
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }