protected void btnQueryAddUpd_Click(object sender, EventArgs e) { if (fldSelectedKey.Value != "") { Guid InspectionId = new Guid(fldSelectedKey.Value); string Mode = "Upd"; if (null == ViewState["InspectionQueryListDetails"]) { ViewState["InspectionQueryListDetails"] = new Inspection().GetInspectionQueriesByInspectionId(InspectionId); } GridView GvInspectionQueries = ((GridView)WzInspectionUpd.FindControl("GvInspectionQueries" + Mode)); DataTable dtInspectionQueryListDetails = (DataTable)ViewState["InspectionQueryListDetails"]; DropDownList ddlCheckListId = ((DropDownList)WzInspection.FindControl("ddlCheckListId" + Mode)); TextBox txtQuery = (TextBox)WzInspection.FindControl("txtQuery" + Mode); TextBox txtQueryRemarks = (TextBox)WzInspection.FindControl("txtQueryRemarks" + Mode); DataRow dr = dtInspectionQueryListDetails.NewRow(); dr["QueryId"] = Guid.NewGuid(); dr["InspectionId"] = Guid.Empty; dr["CheckListId"] = ddlCheckListIdUpd.SelectedItem.Value; dr["Description"] = ddlCheckListIdUpd.SelectedItem.Text; dr["Query"] = txtQueryUpd.Text; dr["Remarks"] = txtQueryRemarksUpd.Text; dtInspectionQueryListDetails.Rows.Add(dr); ViewState["InspectionQueryListDetails"] = dtInspectionQueryListDetails; GvInspectionQueriesUpd.DataSource = (DataTable)ViewState["InspectionQueryListDetails"]; GvInspectionQueriesUpd.DataBind(); txtQueryUpd.Text = ""; txtQueryRemarksUpd.Text = ""; } }
protected void btnQueryUpdateIns_Click(object sender, EventArgs e) { string Mode = "Ins"; Guid InspectionId = Guid.Empty; if (null == ViewState["InspectionQueryListDetails"]) { ViewState["InspectionQueryListDetails"] = new Inspection().GetInspectionQueriesByInspectionId(Guid.Empty); InspectionId = Guid.Empty; } GridView GvInspectionQueries = ((GridView)WzInspection.FindControl("GvInspectionQueries" + Mode)); DataTable dtInspectionQueryListDetails = (DataTable)ViewState["InspectionQueryListDetails"]; DropDownList ddlCheckListId = ((DropDownList)WzInspection.FindControl("ddlCheckListId" + Mode)); TextBox txtQuery = ((TextBox)WzInspection.FindControl("txtQuery" + Mode)); TextBox txtQueryRemarks = ((TextBox)WzInspection.FindControl("txtQueryRemarks" + Mode)); object[] keys = { GvInspectionQueries.SelectedDataKey.Value }; DataRow dr = dtInspectionQueryListDetails.Rows.Find(keys); if (null != dr) { dr["CheckListId"] = ddlCheckListId.SelectedValue; dr["Query"] = txtQuery.Text; dr["Remarks"] = txtQueryRemarks.Text; } ((Button)WzInspection.FindControl("btnQueryAdd" + Mode)).Visible = true; ((Button)WzInspection.FindControl("btnQueryUpdate" + Mode)).Visible = false; GvInspectionQueries.DataSource = (DataTable)ViewState["InspectionQueryListDetails"]; GvInspectionQueries.DataBind(); GvInspectionQueries.SelectedIndex = -1; txtQuery.Text = ""; txtQueryRemarks.Text = ""; }