protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e) { Label lblPrdId = ((Label)ListView1.Items[e.ItemIndex].FindControl("lblPkId")); TextBox txtPrdId = ((TextBox)ListView1.Items[e.ItemIndex].FindControl("txtpdtId")); TextBox txtPrdName = ((TextBox)ListView1.Items[e.ItemIndex].FindControl("txtPdtName")); TextBox txtPrdLoc = ((TextBox)ListView1.Items[e.ItemIndex].FindControl("txtPdtLoc")); TextBox txtPrdQty = ((TextBox)ListView1.Items[e.ItemIndex].FindControl("txtPdtQty")); TextBox txtPrdPrice = ((TextBox)ListView1.Items[e.ItemIndex].FindControl("txtPDtPrce")); getRowCount = _ObjBusiness.UpdateDetails(Convert.ToInt32(lblPrdId.Text), txtPrdId.Text, txtPrdName.Text, txtPrdLoc.Text, txtPrdQty.Text, txtPrdPrice.Text); if (getRowCount > 0) { ListView1.EditIndex = -1; BindData(); lblmsg.Text = "Successfully Updated!..."; } else { ListView1.EditIndex = -1; BindData(); lblmsg.Text = "Update Operation failed!..."; } lblmsg.Text = "Successfully Updated!..."; }
protected void _listviewProjAss_ItemUpdating(object sender, ListViewUpdateEventArgs e) { Label PROJIDLabel = (Label)_listviewProjAss.EditItem.FindControl("PROJIDLabel"); DropDownList _dropdownProjectStat = (DropDownList)_listviewProjAss.EditItem.FindControl("_dropdownProjectStat"); if (_dropdownProjectStat.SelectedValue.Equals("Finish")) { String Conn = ConfigurationManager.ConnectionStrings["ConnString_WEB_ASSET_DB"].ConnectionString; SqlConnection Connect = new SqlConnection(Conn); Connect.Open(); SqlCommand Cmd = new SqlCommand("UPDATE ASSIGNEDEQUIP SET ASSEQUIPQUANT='0' WHERE PROJID=@ProjectID", Connect); Cmd.Parameters.AddWithValue("@ProjectID", PROJIDLabel.Text); Cmd.ExecuteNonQuery(); Connect.Close(); Connect.Open(); Cmd = new SqlCommand("UPDATE WORKER SET WORKER.ASSWORKER='False' FROM WORKER JOIN ASSIGNEDWORKER ON WORKER.WORKERID=ASSIGNEDWORKER.WORKERID WHERE ASSIGNEDWORKER.PROJID=@ProjectID", Connect); Cmd.Parameters.AddWithValue("@ProjectID", PROJIDLabel.Text); Cmd.ExecuteNonQuery(); Connect.Close(); Connect.Open(); Cmd = new SqlCommand("UPDATE ASSIGNEDWORKER SET INTHISPROJ='False' FROM ASSIGNEDWORKER WHERE PROJID=@ProjectID", Connect); Cmd.Parameters.AddWithValue("@ProjectID", PROJIDLabel.Text); Cmd.ExecuteNonQuery(); ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Equipments Returned and some Workers are now Available!');", true); Connect.Close(); } }
protected void CaseListView_ItemUpdating(object sender, ListViewUpdateEventArgs e) { DropDownList ddlOrigen = (DropDownList)CaseListView.Items[e.ItemIndex].FindControl("ddlUser"); CaseDataSource.UpdateParameters["CaseID"].DefaultValue = CaseID; CaseDataSource.UpdateParameters["UserID"].DefaultValue = ddlOrigen.SelectedValue; }
protected void OnItemUpdating(object sender, ListViewUpdateEventArgs e) { string nino = (ListView1.Items[e.ItemIndex].FindControl("lblNationalIdNumber") as Label).Text; string department = (ListView1.Items[e.ItemIndex].FindControl("ddlDepartment") as DropDownList).SelectedItem.Value; string departmen1t = (ListView1.Items[e.ItemIndex].FindControl("ddlDepartment") as DropDownList).SelectedValue.ToString(); //DataTable dtd = (DataTable)ViewState["dtDepartments"]; DataTable dtd = dtDepartments; SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString); foreach (DataRow row in dtd.Rows) { if (row["NationalIdNumber"].ToString() == nino) { row["Name"] = departmen1t; SqlCommand cmd = new SqlCommand("SELECT BusinessEntityId From HumanResources.Employee Where NationalIdNumber = '" + nino + " '", connection); connection.Open(); var businessEntityId = cmd.ExecuteScalar().ToString(); cmd = new SqlCommand("update HumanResources.EmployeeDepartmentHistory set DepartmentId='" + department + "' where BusinessEntityId ='" + Convert.ToInt32(businessEntityId) + "'", connection); cmd.ExecuteNonQuery(); break; } } ListView1.EditIndex = -1; rtnInitialization(); }
protected void DiplomaEntReqList_ItemUpdating(object sender, ListViewUpdateEventArgs e) { MessageUserControl.TryRun(() => { string errorList = ""; bool result; int mark; ListViewItem item = DiplomaEntReqList.Items[e.ItemIndex]; result = int.TryParse((item.FindControl("MarkTextBox") as TextBox).Text.Trim(), out mark); if (!result) { errorList += "- Marks entered must be whole numbers. \\n"; } if (mark < 0 || mark > 100) { errorList += "- Marks must be whole numbers between 1 - 99. \\n"; } if (errorList != "") { e.Cancel = true; throw new Exception(errorList); } }); }
/* * @Method: EditVenueList_ItemUpdating * @Params: object sender, ListViewDeleteEventArgs e * @Return: void * @Description: This method will be activated on the click of Promote * or Demote venue button. It will decide whether the command is for promotion * or demotion, and then update the database accordingly */ protected void EditVenuesList_ItemUpdating(object sender, ListViewUpdateEventArgs e) { string query = null; venueID = EditVenuesList.SelectedDataKey.Value.ToString(); if (updateArgument == "Promote") { query = "update Venues set IsPromoted=1 where VenueID ='" + venueID + "'"; } else if (updateArgument == "Demote") { query = "update Venues set IsPromoted=0 where VenueID ='" + venueID + "'"; } string result = dbCommander.UpdateRecord(query); //If update is successful if (result == "1") { //Closing database connection dbCommander.CloseConnection(); //Turn the list into default EditVenuesList.SelectedIndex = -1; EditVenuesList.DataBind(); } }
/* * @Method: UnApprovedList_ItemUpdating * @Params: object sender, ListViewDeleteEventArgs e * @Return: void * @Description: This method will be activated on the click of Approve * venue button. It will pick the VenueID and update the database * accordingly */ protected void UnApprovedList_ItemUpdating(object sender, ListViewUpdateEventArgs e) { string query = null; venueID = UnApprovedList.SelectedDataKey.Value.ToString(); query = "update Venues set IsApproved=1 where VenueID ='" + venueID + "'"; string result = dbCommander.UpdateRecord(query); //If update is successful if (result == "1") { //Closing database connection dbCommander.CloseConnection(); //Turn the list into default UnApprovedList.SelectedIndex = -1; UnApprovedList.DataBind(); //Showing success message ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Alert", "alert('Venue approved successfully');", true); } }
protected void Update_Command(object sender, ListViewUpdateEventArgs e) { MessageUserControl.TryRun(() => { MessageUserControl.Visible = true; UserProfile user = new UserProfile(); Utility utility = new Utility(); user.FirstName = (UserListViewEdit.EditItem.FindControl("FirstNameLabel") as TextBox).Text; user.LastName = (UserListViewEdit.EditItem.FindControl("LastNameLabel") as TextBox).Text; user.SiteId = int.Parse((UserListViewEdit.EditItem.FindControl("SiteDropDownList") as DropDownList).SelectedValue); user.RequestedPassword = (UserListViewEdit.EditItem.FindControl("RequestedPasswordLabel") as TextBox).Text; user.UserName = (UserListViewEdit.EditItem.FindControl("UserNameLabel") as Label).Text; user.Active = (disabledCheckBox.Checked); utility.checkValidString(user.RequestedPassword); utility.checkValidString(user.FirstName); utility.checkValidString(user.LastName); // check to see if the user being edited is the webmaster if ((UserListViewEdit.EditItem.FindControl("UserNameLabel") as Label).Text != "Webmaster") { // change the role of non webmasters var roleList = new List <string>(); roleList.Add((UserListViewEdit.EditItem.FindControl("RoleMembershipsDropDown") as DropDownList).SelectedValue); user.RoleMemberships = roleList; } user.Active = (UserListViewEdit.EditItem.FindControl("disabledCheckBox") as CheckBox).Checked; UserManager sysmgr = new UserManager(); sysmgr.UpdateUser(user); UserListViewEdit.EditIndex = -1; List <UserProfile> info = sysmgr.ListUser_BySearchParams(username, site, role, status); UserListViewEdit.DataSource = info; UserListViewEdit.DataBind(); UserListView.DataBind(); }, "Success", "Successfully updated users"); }
// Populate screen protected void lstAllUsers_ItemUpdating(object sender, ListViewUpdateEventArgs e) { USER user = new USER(); TextBox tbx = (lstAllUsers.Items[e.ItemIndex].FindControl("tbxUsername")) as TextBox; if (tbx != null) { user.Username = tbx.Text; } tbx = (lstAllUsers.Items[e.ItemIndex].FindControl("tbxPassword")) as TextBox; if (tbx != null) { user.Password = tbx.Text; } tbx = (lstAllUsers.Items[e.ItemIndex].FindControl("tbxFirstname")) as TextBox; if (tbx != null) { user.Firstname = tbx.Text; } tbx = (lstAllUsers.Items[e.ItemIndex].FindControl("tbxSurname")) as TextBox; if (tbx != null) { user.Surname = tbx.Text; } UpdateUserRecord(user, "Modify"); ResetUserView(); }
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e) { string ywycode = (string)e.NewValues["YwyCode"]; if (ywycode.Trim().Length == 0) { e.Cancel = true; Show(this, "请输入业务员代码"); return; } string ywyname = (string)e.NewValues["YwyName"]; if (ywyname.Trim().Length == 0) { e.Cancel = true; Show(this, "请输入业务员姓名"); return; } string ywyid = e.Keys[0].ToString(); string updatesql = "UPDATE YwyInfo SET YwyCode = '" + ywycode.Trim() + "', YwyName = '" + ywyname.Trim() + "' WHERE (YwyID = " + ywyid + ")"; SqlDataSource1.UpdateCommand = updatesql; }
protected void _listviewMtrlCtgryCrud_ItemUpdating(object sender, ListViewUpdateEventArgs e) { TextBox MATERIALCTGRYNAMETextBox = (TextBox)_listviewMtrlCtgryCrud.EditItem.FindControl("MATERIALCTGRYNAMETextBox"); String Conn = ConfigurationManager.ConnectionStrings["ConnString_WEB_ASSET_DB"].ConnectionString; SqlConnection Connect = new SqlConnection(Conn); string MaterialCatName = MATERIALCTGRYNAMETextBox.Text.Trim(); string MatCatID = e.Keys[0].ToString().Trim(); Connect.Open(); SqlCommand Cmd = new SqlCommand("SELECT COUNT (*) FROM MATERIALCTGRY WHERE MATERIALCTGRYNAME=@MaterialCatName AND MATERIALCTGRYID!=@MatCatID", Connect); Cmd.Parameters.AddWithValue("@MaterialCatName", MaterialCatName); Cmd.Parameters.AddWithValue("@MatCatID", MatCatID); Int32 Count = (Int32)Cmd.ExecuteScalar(); if (Count > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Category Name is already existing.')", true); e.Cancel = true; // if (e.OldValues["MATERIALCTGRYNAME"].ToString() == MaterialCatName) //{ //} } }
protected void UpdateRecord(object sender, ListViewUpdateEventArgs e) { int autoId = int.Parse(ListView1.DataKeys[e.ItemIndex].Value.ToString()); ListViewItem item = ListView1.Items[e.ItemIndex]; TextBox tqty = (TextBox)item.FindControl("txtquantity"); TextBox tdosage = (TextBox)item.FindControl("txtdosage"); DropDownList ddlDrugName = (DropDownList)item.FindControl("ddldrugName"); List <test> lstvst = null; lstvst = ViewstateDrugNames; test tst = lstvst.Where(t => t.AutoID == autoId).SingleOrDefault(); tst.Quantity = tqty.Text; tst.Dosage = tdosage.Text; tst.DrugName = ddlDrugName.SelectedItem.ToString(); tst.DrugNameId = ddlDrugName.SelectedValue; ViewstateDrugNames = lstvst; //lblMessage.Text = "Record updated successfully !"; ListView1.EditIndex = -1; // repopulate the data this.PopulateData(); }
protected void ChequesNoEntregados_ListView_ItemUpdating(object sender, ListViewUpdateEventArgs e) { // convertimos el valor indicado por el usuario a datetime System.Globalization.CultureInfo culture; System.Globalization.DateTimeStyles styles; DateTime dateResult; String sCultureName = System.Threading.Thread.CurrentThread.CurrentCulture.Name; culture = System.Globalization.CultureInfo.CreateSpecificCulture(sCultureName); styles = System.Globalization.DateTimeStyles.None; if (!(e.NewValues["FechaEntregado"] == null) && DateTime.TryParse(e.NewValues["FechaEntregado"].ToString(), culture, styles, out dateResult)) { e.NewValues["FechaEntregado"] = dateResult; } else { ErrMessage_Span.InnerHtml = "Aparentemente, el valor indicado para la fecha no es válido."; ErrMessage_Span.Style["display"] = "block"; e.Cancel = true; } }
protected void lvEducation_ItemUpdating(object sender, ListViewUpdateEventArgs e) { TextBox txtInstitutionName = (TextBox)(lvEducation.Items[e.ItemIndex].FindControl("txtInstitutionName")) as TextBox; TextBox txtDegreeTitle = (TextBox)(lvEducation.Items[e.ItemIndex].FindControl("txtDegreeTitle")) as TextBox; DropDownList DDCategory = (DropDownList)(lvEducation.Items[e.ItemIndex].FindControl("DDCategory")) as DropDownList; TextBox txtBatch = (TextBox)(lvEducation.Items[e.ItemIndex].FindControl("txtBatch")) as TextBox; Literal litPK = (Literal)(lvEducation.Items[e.ItemIndex].FindControl("litPK")) as Literal; String InstitutionName = "", DegreeTitle = "", Category = "", Batch = ""; InstitutionName = txtInstitutionName.Text; DegreeTitle = txtDegreeTitle.Text; Category = DDCategory.Text; Batch = txtBatch.Text; String cmdStr = "UPDATE Education SET Category = '" + Category + "', Batch = '" + Batch + "', " + "DegreeTitle = '" + DegreeTitle + "', InstitutionName = '" + InstitutionName + "' " + "WHERE Education_PK = '" + litPK.Text + "'"; SqlCommand scom = new SqlCommand(cmdStr, con); con.Open(); Boolean flg = false; //If there is an error no PostBack// if ((InstitutionName == "") || (DegreeTitle == "") || (Category == "") || (Batch == "")) { lblErrorInsert.Text = "Check the Entries, Date should be (MM/DD/YYYY)"; lblErrorInsert.Visible = true; flg = true; } try { if (!flg) { scom.ExecuteNonQuery(); } } catch { //Most Probably it is the date issue// //Give a msg saying the date should be in correct format// //And Recheck other entries// lblErrorInsert.Text = "Check the Entries, Date should be (MM/DD/YYYY)"; lblErrorInsert.Visible = true; flg = true; } finally { con.Close(); } if (!flg) { Server.Transfer("editEducation.aspx"); } }
protected void ListViewCities_ItemUpdating(object sender, ListViewUpdateEventArgs e) { this.LabelCityErrors.Text = string.Empty; try { string cityName = (this.ListViewCities.Items[e.ItemIndex].FindControl("CityNameTextBox") as TextBox).Text; this.ValidateName(cityName); float latitude; string latitudeAsString = (this.ListViewCities.Items[e.ItemIndex].FindControl("LatitudeTextBox") as TextBox).Text; this.ValidateGeoCoordinate(latitudeAsString, out latitude); float longitude; string longitudeAsString = (this.ListViewCities.Items[e.ItemIndex].FindControl("LongitudeTextBox") as TextBox).Text; this.ValidateGeoCoordinate(longitudeAsString, out longitude); int population; string populationAsString = (this.ListViewCities.Items[e.ItemIndex].FindControl("PopulationTextBox") as TextBox).Text; this.ValidatePopulation(populationAsString, out population); } catch (DbEntityValidationException ex) { var errors = ex.EntityValidationErrors .SelectMany(eve => eve.ValidationErrors) .Select(ve => ve.ErrorMessage); this.LabelCityErrors.Text = string.Join(", ", errors); e.Cancel = true; } catch (Exception ex) { this.LabelCityErrors.Text = ex.Message; e.Cancel = true; } }
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e) { //Label lbl = (ListView1.Items[e.ItemIndex].FindControl("PostIdLabel")) as Label; //if (lbl != null) postId_edit = new Guid(lbl.Text); //TextBox txt = (ListView1.Items[e.ItemIndex].FindControl("PostTextBox")) as TextBox; // String edit_text = txt.Text; }
protected void postsView_ItemUpdating(object sender, ListViewUpdateEventArgs e) { var postTextBox = this.postsListView.EditItem.FindControl("Text") as TextBox; var postIdField = this.postsListView.EditItem.FindControl("Id") as HiddenField; var post = PostService.Get(CustomConvert.ToInt32(postIdField.Value)); if (post.CreatedBy != SecurityContext.User) { throw new NotAuthorizedException(); } try { post.Edit(postTextBox.Text); PostService.Update(post); PostService.CommitChanges(); Response.RedirectToRoute("TopicPosts", new { topicId = this.topicId.Value }); } catch { //handle exception this.message.InnerText = GenericErrorMessage; this.message.Visible = true; } }
protected void my_in_view_ItemUpdating(object sender, ListViewUpdateEventArgs e) { //Label cas_id = (Label)my_in_view.Items[e.ItemIndex].FindControl("cas_idLabel"); //DropDownList _drsys = (DropDownList)my_in_view.Items[e.ItemIndex].FindControl("drsrv"); //TextBox reff = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("reff_TextBox"); //TextBox cate = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("cate_TextBox"); //TextBox zone = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("b_zoneTextBox"); //TextBox level = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("f_levelTextBox"); //TextBox seq = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("seq_noTextBox"); //TextBox desc = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("desc_TextBox"); //TextBox loca = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("loca_TextBox"); //TextBox power = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("p_power_toTextBox"); //TextBox fed = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("fed_fromTextBox"); //BasicFrame.WebControls.BasicDatePicker power_on = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_power_on"); //BasicFrame.WebControls.BasicDatePicker torque = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_torque"); //BasicFrame.WebControls.BasicDatePicker ir = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_ir"); //BasicFrame.WebControls.BasicDatePicker pressure = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_pressure"); //BasicFrame.WebControls.BasicDatePicker sec = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_sec"); //BasicFrame.WebControls.BasicDatePicker con = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_con"); //BasicFrame.WebControls.BasicDatePicker fun = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_fun"); //TextBox dvc = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("devicesTextBox"); //TextBox c_t = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("ttl_cold_testedTextBox"); //BasicFrame.WebControls.BasicDatePicker c_c = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_c_c"); //TextBox l_t = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("ttl_live_testedTextBox"); //BasicFrame.WebControls.BasicDatePicker l_c = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_l_c"); //BasicFrame.WebControls.BasicDatePicker con_acce = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_con_acc"); //TextBox comm = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("comm_TextBox"); //TextBox act_by = (TextBox)my_in_view.Items[e.ItemIndex].FindControl("act_byTextBox"); //BasicFrame.WebControls.BasicDatePicker act_date = (BasicFrame.WebControls.BasicDatePicker)my_in_view.Items[e.ItemIndex].FindControl("dt_act"); //Edit_Cas_Main(Convert.ToInt32(cas_id.Text), Convert.ToInt32(_drsys.SelectedItem.Value), reff.Text, loca.Text, power.Text, fed.Text, desc.Text, Convert.ToInt32(dvc.Text), Convert.ToDateTime(power_on.Text), comm.Text, Convert.ToDateTime(con_acce.Text), act_by.Text, Convert.ToDateTime(act_date.Text)); my_in_view.EditIndex = -1; Load_Ini_Data(); }
protected void lvIdf_ItemUpdating(object sender, ListViewUpdateEventArgs e) { TextBox txt = lvIdf.Items[e.ItemIndex].FindControl("txtEdSno") as TextBox; int sno = Convert.ToInt16(txt.Text); DropDownList ddl = (DropDownList)lvIdf.Items[e.ItemIndex].FindControl("ddlEdIdf"); string idf = ddl.SelectedValue; ddl = (DropDownList)lvIdf.Items[e.ItemIndex].FindControl("ddlEdgrp"); string grp = ddl.SelectedValue; txt = (TextBox)lvIdf.Items[e.ItemIndex].FindControl("txtEdamt"); string amt = txt.Text; txt = (TextBox)lvIdf.Items[e.ItemIndex].FindControl("txtEdrem"); string rem = txt.Text; DataTable dt = (DataTable)ViewState["rcpt"]; foreach (DataRow dr in dt.Rows) { if (Convert.ToInt16(dr["Slno"]) == sno) { dr["FileNo"] = idf; dr["RGroup"] = grp; dr["SplitAmtInr"] = amt; dr["Remarks"] = rem; } } lvIdf.EditIndex = -1; lvIdf.DataSource = (DataTable)ViewState["rcpt"]; lvIdf.DataBind(); }
protected void lvBusiness_ItemUpdating(object sender, ListViewUpdateEventArgs e) { string slno = ""; string business = ""; string product = ""; TextBox txt; Label lbl; lbl = lvBusiness.Items[e.ItemIndex].FindControl("lblSlNo") as Label; slno = lbl.Text; txt = lvBusiness.Items[e.ItemIndex].FindControl("txtEditBusiness") as TextBox; business = txt.Text; txt = lvBusiness.Items[e.ItemIndex].FindControl("txtEditProduct") as TextBox; product = txt.Text; DataTable dt = (DataTable)ViewState["BATable"]; foreach (DataRow dr in dt.Rows) { if (dr["SlNo"].ToString() == slno) { dr["BusinessArea"] = business; dr["Products"] = product; dr.AcceptChanges(); } } lvBusiness.EditIndex = -1; lvBusiness.DataSource = (DataTable)ViewState["BATable"]; lvBusiness.DataBind(); }
void lvMain_ItemUpdating(object sender, ListViewUpdateEventArgs e) { // get Id being updated int id = Int32.Parse(lvMain.DataKeys[lvMain.EditIndex].Value.ToString()); // get the current item being edited ListViewItem item = lvMain.Items[lvMain.EditIndex]; if (_ShippingMethodDto != null && _ShippingMethodDto.ShippingPackage.Count > 0) { ShippingMethodDto.ShippingPackageRow row = _ShippingMethodDto.ShippingPackage.FindByShippingPackageId(id); DropDownList ddl = (DropDownList)item.FindControl("PackagesList"); if (ddl != null && ddl.Items.Count > 0) { row.PackageId = Int32.Parse(ddl.SelectedValue); } TextBox tbName = item.FindControl("tbPackageName") as TextBox; if (tbName != null) { row.PackageName = tbName.Text; } } // exit the edit mode lvMain.EditIndex = -1; // bind the listview BindForm(); }
//private void LoadDetailListView(ListView detailListView, string policyNumber) //{ // SqlConnection sqlConnection1 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["IASDBContext"].ToString()); // SqlCommand cmd = new SqlCommand(); // SqlDataAdapter da = new SqlDataAdapter(); // DataTable dt = new DataTable(); // long caseID = long.Parse(Request.QueryString["CaseID"]); // try // { // cmd.CommandText = "[collection].[sp_get_collections_by_policy]"; // cmd.CommandType = CommandType.StoredProcedure; // cmd.Connection = sqlConnection1; // cmd.Parameters.AddWithValue("@PolicyNumber", policyNumber); // cmd.Parameters.AddWithValue("@CaseID", caseID); // da.SelectCommand = cmd; // da.Fill(dt); // // Load certificate // if (dt?.Rows.Count > 0) // { // detailListView.DataSource = da; // detailListView.DataBind(); // } // else // { // ErrorLabel.Text = "No existen registros del certificado"; // ErrorLabel.Visible = true; // } // } // catch (Exception exp) // { // ErrorLabel.Text = exp.Message; // ErrorLabel.Visible = true; // } //} protected void DetailListView_ItemUpdating(object sender, ListViewUpdateEventArgs e) { var lv = sender as ListView; Label lblCollectionID = (Label)lv.Items[e.ItemIndex].FindControl("lblCollectionID"); CheckBox chkCollected = (CheckBox)lv.Items[e.ItemIndex].FindControl("chkCollected"); TextBox txtEffectiveDate = (TextBox)lv.Items[e.ItemIndex].FindControl("txtEffectiveDate"); DropDownList ddlCollectionState = (DropDownList)lv.Items[e.ItemIndex].FindControl("ddlCollectionState"); SqlDataSource ds = (SqlDataSource)lv.FindControl("CollectionSqlDatSource"); long collectionID = long.Parse(lblCollectionID.Text); var db = new ApplicationDbContext(); var theCollection = db.Collections.SingleOrDefault(c => c.CollectionID == collectionID); if (theCollection == null) { ModelState.AddModelError("", String.Format("No se encontró el elemento con id. {0}", lblCollectionID.Text)); return; } theCollection.Collected = chkCollected.Checked; if (txtEffectiveDate.Text == string.Empty) { theCollection.CollectedDate = DateTime.Today; } else { theCollection.CollectedDate = DateTime.Parse(txtEffectiveDate.Text); } theCollection.CollectionStateID = int.Parse(ddlCollectionState.SelectedValue); db.SaveChanges(); }
protected void UpdateRecord(object sender, ListViewUpdateEventArgs e) { string ReligionID = ListView1.DataKeys[e.ItemIndex].Value.ToString(); ListViewItem item = ListView1.Items[e.ItemIndex]; TextBox txteReligionname = (TextBox)item.FindControl("txteReligionName"); ResultDTO resultDTO = objITransactionBusiness.UpdateSubCenter(PHCConstant.PHCID, ReligionID, txteReligionname.Text); if (resultDTO.IsSuccess) { pnlstatus.BackColor = System.Drawing.ColorTranslator.FromHtml(PHCConstant.SuccessBackGroundColor); lblstatus.ForeColor = System.Drawing.ColorTranslator.FromHtml(PHCConstant.SuccessForeColor); lblstatus.Text = resultDTO.Message; ListView1.EditIndex = -1; this.PopulateData(); } else { pnlstatus.BackColor = System.Drawing.ColorTranslator.FromHtml(PHCConstant.ErrorBackGroundColor); lblstatus.ForeColor = System.Drawing.ColorTranslator.FromHtml(PHCConstant.ErrorForeColor); lblstatus.Text = resultDTO.Message; } //lblMessage.Text = "Record updated successfully !"; // repopulate the data }
void lvAttributeValues_ItemUpdating(object sender, ListViewUpdateEventArgs e) { PlaceHolder phEditValue = lvAttributeValues.EditItem.FindControl("phEditValue") as PlaceHolder; if (phEditValue != null && phEditValue.Controls.Count == 1) { string value = _attribute.FieldType.Field.GetEditValue(phEditValue.Controls[0], _attribute.QualifierValues); var attributeValueService = new AttributeValueService(); var attributeValue = attributeValueService.Get(( int )e.Keys["Id"]); if (attributeValue == null) { attributeValue = new AttributeValue(); attributeValueService.Add(attributeValue, _currentPersonId); attributeValue.AttributeId = _attribute.Id; attributeValue.EntityId = _model.Id; } attributeValue.Value = value; attributeValueService.Save(attributeValue, _currentPersonId); _model.LoadAttributes(); } lvAttributeValues.EditIndex = -1; BindData(); }
protected void UpdateRecord(object sender, ListViewUpdateEventArgs e) { string TalukID = LVTalukDetails.DataKeys[e.ItemIndex].Value.ToString(); ListViewItem item = LVTalukDetails.Items[e.ItemIndex]; TextBox txteTalukName = (TextBox)item.FindControl("txteTalukName"); DropDownList ddlDistrict = (DropDownList)item.FindControl("ddlDistrict"); ResultDTO resultDTO = objITransactionBusiness.UpdateMTaluk(TalukID, ddlDistrict.SelectedValue, txteTalukName.Text); if (resultDTO.IsSuccess) { pnlstatus.BackColor = System.Drawing.ColorTranslator.FromHtml(PHCConstant.SuccessBackGroundColor); lblstatus.ForeColor = System.Drawing.ColorTranslator.FromHtml(PHCConstant.SuccessForeColor); lblstatus.Text = resultDTO.Message; LVTalukDetails.EditIndex = -1; this.PopulateData(); } else { pnlstatus.BackColor = System.Drawing.ColorTranslator.FromHtml(PHCConstant.ErrorBackGroundColor); lblstatus.ForeColor = System.Drawing.ColorTranslator.FromHtml(PHCConstant.ErrorForeColor); lblstatus.Text = resultDTO.Message; } //lblMessage.Text = "Record updated successfully !"; // repopulate the data }
/// <summary> /// Handles the ItemUpdating event of the lvCartItem control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ListViewUpdateEventArgs"/> instance containing the event data.</param> protected void lvCartItem_ItemUpdating(object sender, ListViewUpdateEventArgs e) { ListViewItem row = lvCartItems.Items[e.ItemIndex]; var quantityTextBox = row.FindControl("Quantity") as TextBox; decimal newQuantity; if (!decimal.TryParse(quantityTextBox.Text, out newQuantity)) { BindData(); return; } int lineItemId; if (!Int32.TryParse(lvCartItems.DataKeys[e.ItemIndex].Value.ToString(), out lineItemId)) { return; } if (!CartHelper.IsEmpty) { foreach (var item in CartHelper.LineItems) { var discounts = from Discount discount in item.Discounts where discount.DiscountName.EndsWith(":Gift") select discount; if (discounts.Any()) { ErrorManager.GenerateError(string.Format("[{0}]: {1}", item.DisplayName, "You can not change the quality of items of gift promotion")); return; } if (item.LineItemId == lineItemId) { if (item.Quantity != newQuantity) { var errorMessage = ""; var entry = CatalogContext.Current.GetCatalogEntry(item.CatalogEntryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo | CatalogEntryResponseGroup.ResponseGroup.Inventory)); if (SampleStoreHelper.AllowAddToCart(CartHelper.Cart, entry, true, newQuantity, item.WarehouseCode, out errorMessage)) { item.Quantity = newQuantity; CartHelper.Cart.AcceptChanges(); } else { ErrorManager.GenerateError(string.Format("[{0}]: {1}", item.DisplayName, errorMessage)); return; } } break; } } } Context.RedirectFast(Request.RawUrl); }
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e) { ListView lst = sender as ListView; DropDownList ddl = lst.Items[e.ItemIndex].FindControl("GenderTextBox") as DropDownList; ProfileDS.UpdateParameters["Gender"].DefaultValue = ddl.SelectedValue; DropDownList ddlDay = lst.Items[e.ItemIndex].FindControl("Day") as DropDownList; DropDownList ddlMonth = lst.Items[e.ItemIndex].FindControl("Month") as DropDownList; DropDownList ddlYear = lst.Items[e.ItemIndex].FindControl("Year") as DropDownList; ProfileDS.UpdateParameters["Day"].DefaultValue = ddlDay.SelectedValue; ProfileDS.UpdateParameters["Month"].DefaultValue = ddlMonth.SelectedValue; ProfileDS.UpdateParameters["Year"].DefaultValue = ddlYear.SelectedValue; CheckBoxList cbl = lst.Items[e.ItemIndex].FindControl("InterestedCheckBox") as CheckBoxList; //IEnumerable<string> CheckedItems = cbl.Items.Cast<ListItem>() // .Where(i => i.Selected) // .Select(i => i.Value); //foreach (string i in CheckedItems){ // string s1 = i; //} int numSelected = 0; foreach (ListItem li in cbl.Items) { if (li.Selected) { numSelected = numSelected + 1; } } if (numSelected == 0) { interested = "None"; ProfileDS.UpdateParameters["Interested"].DefaultValue = interested; } if (numSelected == 1) { if (cbl.Items[0].Selected) { interested = cbl.Items[0].Text; ProfileDS.UpdateParameters["Interested"].DefaultValue = interested; } if (cbl.Items[1].Selected) { interested = cbl.Items[1].Text; ProfileDS.UpdateParameters["Interested"].DefaultValue = interested; } } if (numSelected == 2) { interested = "Male and Female"; ProfileDS.UpdateParameters["Interested"].DefaultValue = interested; } DropDownList ddlRelationship = lst.Items[e.ItemIndex].FindControl("ddlRelationship") as DropDownList; ProfileDS.UpdateParameters["Relationship"].DefaultValue = ddlRelationship.SelectedValue; }
protected void lv_B2CS_ItemUpdating(object sender, ListViewUpdateEventArgs e) { try { LinkButton lkbUpdate = (lv_B2CS.Items[e.ItemIndex].FindControl("lkbUpdate")) as LinkButton; if (lkbUpdate.CommandName == "Update") { int id = Convert.ToInt32(lkbUpdate.CommandArgument); byte Rate; GST_TRN_OFFLINE_INVOICE_DATAITEM invoice = unitOfwork.OfflineinvoicedataitemRepository.Filter(x => x.OfflineDataID == id).SingleOrDefault(); if (invoice != null) { DropDownList ddlType = (lv_B2CS.Items[e.ItemIndex].FindControl("ddlType")) as DropDownList; if (ddlType != null) { invoice.GST_TRN_OFFLINE_INVOICE.Type = Convert.ToByte(ddlType.SelectedValue); } uc_SupplyType_B2CS uc_SupplyTypeB2Cs = (uc_SupplyType_B2CS)lv_B2CS.Items[e.ItemIndex].FindControl("uc_SupplyType_B2CS"); invoice.GST_TRN_OFFLINE_INVOICE.PlaceofSupply = Convert.ToByte(uc_SupplyTypeB2Cs.ddlPos_SelectedValue); invoice.TotalTaxableValue = Convert.ToDecimal(uc_SupplyTypeB2Cs.TotalTaxable_Value); if (uc_SupplyTypeB2Cs.ddlSupplyType_SelectedIndex > 0) { invoice.GST_TRN_OFFLINE_INVOICE.SupplyType = Convert.ToByte(uc_SupplyTypeB2Cs.ddlSupplyType_SelectedValue); } invoice.RateId = Convert.ToInt32(uc_SupplyTypeB2Cs.ddlRate_SelectedValue); invoice.IGSTAmt = Convert.ToDecimal(uc_SupplyTypeB2Cs.IntegratedTax); invoice.CGSTAmt = Convert.ToDecimal(uc_SupplyTypeB2Cs.CentralTax); invoice.SGSTAmt = Convert.ToDecimal(uc_SupplyTypeB2Cs.StateTax); invoice.CessAmt = Convert.ToDecimal(uc_SupplyTypeB2Cs.Cess); TextBox txtECommerce = (lv_B2CS.Items[e.ItemIndex].FindControl("txtECommerce")) as TextBox; if (txtECommerce.Text != null || txtECommerce.Text != "") { invoice.GST_TRN_OFFLINE_INVOICE.ECommerce_GSTIN = txtECommerce.Text; } } //viveksinha-start invoice.GST_TRN_OFFLINE_INVOICE.UserID = Common.LoggedInUserID(); invoice.UpdatedBy = Common.LoggedInUserID(); invoice.UpdatedDate = DateTime.Now; //end unitOfwork.OfflineinvoicedataitemRepository.Update(invoice); unitOfwork.Save(); } lv_B2CS.EditIndex = -1; BindItems(ReturnType); } catch (Exception ex) { cls_ErrorLog ob = new cls_ErrorLog(); cls_ErrorLog.LogError(ex, Common.LoggedInUserID()); } }
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e) { DropDownList ddl = (DropDownList)ListView1.EditItem.FindControl("DropDownList1"); e.NewValues["FK_Users_Message_Recipient"] = ddl.SelectedValue; DropDownList ddl2 = (DropDownList)ListView1.EditItem.FindControl("DropDownList2"); e.NewValues["FK_Users_Message_sender"] = ddl.SelectedValue; }
protected void lvAddress_ItemUpdating(object sender, ListViewUpdateEventArgs e) { string AddrId = "", Address = "", State = "", City = "", Zip = ""; Label lbl = (lvAddress.Items[e.ItemIndex].FindControl("AddressIDLabelSearch2")) as Label; if (lbl != null) { AddrId = lbl.Text; } TextBox txt = (lvAddress.Items[e.ItemIndex].FindControl("txtStreetAddressEditLV")) as TextBox; if (txt != null) { Address = txt.Text; } txt = (lvAddress.Items[e.ItemIndex].FindControl("txtCityEditLV")) as TextBox; if (txt != null) { City = txt.Text; } txt = (lvAddress.Items[e.ItemIndex].FindControl("txtStateAddrEditLV")) as TextBox; if (txt != null) { State = txt.Text; } txt = (lvAddress.Items[e.ItemIndex].FindControl("txtZipEditLV")) as TextBox; if (txt != null) { Zip = txt.Text; } DropDownList dllAddressTypeLV = (lvAddress.Items[e.ItemIndex].FindControl("ddlAddressTypeEditLV")) as DropDownList; string strConnection = ConfigurationManager.ConnectionStrings["ConnectString"].ConnectionString; SqlConnection con = new SqlConnection(strConnection); SqlCommand cmd1 = new SqlCommand(); cmd1.CommandText = @"UPDATE AddressTemp SET AddrType='" + dllAddressTypeLV.SelectedItem + "', StreetAddr='" + Address + "', City='" + City + "',State='" + State + "',Zip='" + Zip + "' where Address_id='" + AddrId + "'"; cmd1.CommandType = CommandType.Text; cmd1.Connection = con; con.Open(); cmd1.ExecuteNonQuery(); con.Close(); lvAddress.EditIndex = -1; FillAddress(); }