protected void cmdAdd_Click(object sender, EventArgs e) { ListItem objListItem; ArrayList objList = new ArrayList(); foreach (ListItem tempLoopVar_objListItem in lstAvailable.Items) { objListItem = tempLoopVar_objListItem; objList.Add(objListItem); } foreach (ListItem tempLoopVar_objListItem in objList) { objListItem = tempLoopVar_objListItem; if (objListItem.Selected) { lstAvailable.Items.Remove(objListItem); lstAssigned.Items.Add(objListItem); } } lstAvailable.ClearSelection(); lstAssigned.ClearSelection(); Sort(lstAssigned); }
private void TextFieldChanged(object source, EventArgs args) { string prefix = itsTextBox.Text; if (prefix.Length == 0) { itsListBox.ClearSelection(); return; } ListItemCollection listItems = itsListBox.Items; bool found = false; for (int i = 0; found == false && i < listItems.Count; i++) { object o = listItems[i]; string s = o.ToString(); if (s.StartsWith(prefix)) { itsListBox.Items[i].Selected = true; found = true; } } if (!found) { itsListBox.ClearSelection(); } }
private void cmdAddSignature_click(object sender, System.EventArgs e) { try { if (lstAllSignatures.SelectedItem == null) { return; } ListItem objListItem = new ListItem(); objListItem = lstAllSignatures.SelectedItem; lstSessionSignatures.Items.Add(objListItem); lstAllSignatures.Items.Remove(objListItem); lstSessionSignatures.ClearSelection(); lstAllSignatures.ClearSelection(); } catch { } lstSessionSignatures_save(); }
private void cmdUrlUp_click(object sender, System.EventArgs e) { try { if (lstUrls.SelectedItem == null) { return; } ListItem objMyListItem; objMyListItem = lstUrls.SelectedItem; int intX = 0; int intY = 0; foreach (ListItem tmpListItem in lstUrls.Items) { if (tmpListItem.Selected == true) { intY = intX; if (intY == 0) { return; } } intX = intX + 1; } lstUrls.Items.Remove(objMyListItem); lstUrls.ClearSelection(); lstUrls.Items.Insert(intY - 1, objMyListItem); intX = 0; foreach (ListItem tmpListItem in lstUrls.Items) { urlsDataAccess.updateOrder(System.Convert.ToInt32(tmpListItem.Value), intX); intX++; } lstUrls_bind(); } catch { } }
protected void btnReset_Click(object sender, EventArgs e) { try { //--reset fields txtKeyword.Text = ""; txtDateFrom.Text = ""; txtDateTo.Text = ""; txtYear.Text = ""; txtMonth.Text = ""; //lbDomain.ClearSelection(); //lbSubDomain.Items.Clear(); //--Get collections RepeaterItemCollection rpCategoriesCollection = rpCategories.Items; for (int i = 0; i < rpCategoriesCollection.Count; i++) { RepeaterItem rpCategoryItem = rpCategoriesCollection[i]; ListBox lbCategory = (ListBox)rpCategoryItem.FindControl("lbCategory"); lbCategory.ClearSelection(); } } catch (RaveHRException ex) { LogErrorMessage(ex); } catch (Exception ex) { RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, PAGE_NAME, "btnReset_Click", EventIDConstants.RAVE_HR_PROJECTS_PRESENTATION_LAYER); LogErrorMessage(objEx); } }
public static void ListBoxSelect(ref ListBox ddl, string value) { ddl.ClearSelection(); ListItem li = ddl.Items.FindByValue(value); if (li != null) { li.Selected = true; } }
protected void PremiereRentreeListBox_SelectedIndexChanged(object sender, EventArgs e) { //PopupControlExtender pce = (PopupControlExtender)ListView1.EditItem.FindControl("PopupControlExtender1"); ListBox lb = (ListBox)ListView1.EditItem.FindControl("PremiereRentreeListBox"); //pce.Commit("Green"); ((TextBox)ListView1.EditItem.FindControl("PremiereRentreeTextBox")).Text = lb.SelectedItem.ToString(); lb.ClearSelection(); }
private void cmdGlobalAll_click(object sender, System.EventArgs e) { foreach (ListItem objGlobalAll in lstGlobalAllPayloads.Items) { ListItem objListItem = new ListItem(); objListItem = objGlobalAll; lstGlobalPayloads.Items.Add(objListItem); lstGlobalPayloads.ClearSelection(); lstGlobalAllPayloads.ClearSelection(); } lstGlobalAllPayloads.Items.Clear(); lstGlobalPayloads_save(); }
/// <summary> /// Select items in a ListBox from a List<string> of values /// </summary> /// <param name="items">List<string> of values to be marked selected</param> /// <param name="listBox">ListBox to be populated</param> public static void SelectListBoxItems(List <string> items, ListBox listBox) { listBox.ClearSelection(); foreach (ListItem listItem in listBox.Items) { if (items.Contains(listItem.Value)) { listItem.Selected = true; } } }
private void cmdAdd_Click(object sender, EventArgs e) { var objList = new ArrayList(); foreach (ListItem objListItem in lstAvailable.Items) { objList.Add(objListItem); } foreach (ListItem objListItem in objList) { if (objListItem.Selected) { lstAvailable.Items.Remove(objListItem); lstAssigned.Items.Add(objListItem); } } lstAvailable.ClearSelection(); lstAssigned.ClearSelection(); Sort(lstAssigned); }
private void SelecionaItemDDL(ListBox ddl, string qsKey) { if (!string.IsNullOrEmpty(Request.QueryString[qsKey])) { ListItem item = ddl.Items.FindByValue(Request.QueryString[qsKey]); if (item != null) { ddl.ClearSelection(); item.Selected = true; } } }
public static void LoadDropDown(System.Data.DataTable dt, ListBox drpSource, string textField, string valueField) { drpSource.SelectedIndex = -1; drpSource.SelectedValue = null; drpSource.ClearSelection(); drpSource.DataSource = dt; drpSource.DataTextField = textField; drpSource.DataValueField = valueField; drpSource.DataBind(); }
public DataTable FillDropDownList1(ListBox dropdown, string query, string valueField, string textField) { try { setQuery(query); dt = QueryEx(); dropdown.ClearSelection(); dropdown.DataSource = dt; dropdown.DataValueField = valueField; dropdown.DataTextField = textField; dropdown.DataBind(); con.Close(); } catch { } return(dt); }
public void ListBoxControl(ListBox lst, String SpName, string datatext, string datavalue, SqlParameter[] PM) { dt1 = SqlHelper.ExecuteDataTable(SqlHelper.conString, CommandType.StoredProcedure, SpName, PM); lst.Items.Clear(); lst.DataTextField = datatext; lst.DataValueField = datavalue; lst.ClearSelection(); //lst.SelectedValue = "0"; if (dt1.Rows.Count != 0) { lst.DataSource = dt1; lst.DataBind(); } dt1.Dispose(); }
public static void SetValue(int boField, bool boFieldIsNull, ListBox lb) { lb.ClearSelection(); if (boFieldIsNull) { return; } else { ListItem li = lb.Items.FindByValue(boField.ToString()); if (!(li == null)) { li.Selected = true; } } }
public static void GetProductBillingType(ListBox listBox) { try { DataTable dt = new DataTable(); listBox.ClearSelection(); DAL_Product_Registration objDAL = new DAL_Product_Registration(); dt = objDAL.Get_ProductBillingType(); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { listBox.Items.Add(new ListItem(row["billing_sub_type"].ToString(), row["billing_dtls_id"].ToString())); } } } catch (Exception ex) { } }
public static void CleanOperation(this ListBox suggestionList, SuggestionCleanupOperation operation, IEnumerable goldenItemSource) { if ((operation & SuggestionCleanupOperation.ClearSelection) == SuggestionCleanupOperation.ClearSelection) { suggestionList.ClearSelection(); } if ((operation & SuggestionCleanupOperation.ResetIndex) == SuggestionCleanupOperation.ResetIndex) { suggestionList.SetSelectionStart(-1); suggestionList.SetSelectionEnd(-1); } if ((operation & SuggestionCleanupOperation.ResetItemSource) == SuggestionCleanupOperation.ResetItemSource) { suggestionList.ItemsSource = goldenItemSource; } }
public void ShowFriendsToListBox(int UserID, ListBox listBox) { listBox.ClearSelection(); // очищаем лист бокс List <int> friendListIDs = GetFriendIDList(UserID); for (int i = 0; i < friendListIDs.Count; i++) { int friendID = GetFriendID(UserID, friendListIDs.ElementAt(i)); string friendName = this.GetPeopleName(friendID); string friendSurname = this.GetPeopleSurname(friendID); ListItem item = new ListItem(); item.Text = friendName + " " + friendSurname; item.Value = Convert.ToString(friendID); listBox.Items.Add(item); } }
private void SelectModule(Module m, string paneName) { ListBox listbox = null; switch (paneName.ToLower()) { case "leftpane": listbox = leftPane; break; case "rightpane": listbox = rightPane; break; case "contentpane": listbox = contentPane; break; case "altcontent1": listbox = lbAltContent1; break; case "altcontent2": listbox = lbAltContent2; break; } if (listbox != null) { ListItem item = listbox.Items.FindByValue(m.ModuleId.ToInvariantString()); if (item != null) { listbox.ClearSelection(); item.Selected = true; } } }
/// <summary> /// вызывать этот метод /// </summary> /// <param name="dialogID"></param> /// <param name="listBox"></param> public void ReadeDialogToListBox(int dialogID, ListBox listBox) { listBox.ClearSelection(); // очищаем лист бокс int maxMesID = getMaxMessageID(dialogID); //считываем сообщения до максимального номера сообщения for (int i = 0; i < maxMesID + 1; i++) { string MessageText = ReadeDialogMessage(dialogID, i); string personName = ReadePersonName(dialogID, i); string personSurname = ReadePersonSurname(dialogID, i); if (MessageText == null) { continue; } ListItem item = new ListItem(); item.Text = personName + " " + personSurname + ": " + MessageText; item.Value = null; listBox.Items.Add(item); } }
private void SetPreviousData() { int rowIndex = 0; if (ViewState["CurrentTable"] != null) { DataTable dt = (DataTable)ViewState["CurrentTable"]; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { DropDownList ddl = (DropDownList)GridviewResourceDetail.Rows[rowIndex].Cells[1].FindControl("ResourceTypeID"); //TextBox box1 = (TextBox)GridviewResourceDetail.Rows[i].Cells[1].FindControl("TextBox1"); TextBox box2 = (TextBox)GridviewResourceDetail.Rows[i].Cells[2].FindControl("NoOfResources"); ListBox ddl1 = (ListBox)GridviewResourceDetail.Rows[rowIndex].Cells[3].FindControl("SkillID"); //DropDownList ddl2 = (DropDownList)GridviewResourceDetail.Rows[rowIndex].Cells[4].FindControl("DropDownList2"); //Fill the DropDownList with Data ClsCommon.ddlGetDesignation(ddl); ClsCommon.ddlGetSkill(ddl1); TextBox box3 = (TextBox)GridviewResourceDetail.Rows[i].Cells[2].FindControl("StartDate"); TextBox box4 = (TextBox)GridviewResourceDetail.Rows[i].Cells[2].FindControl("EndDate"); if (i < dt.Rows.Count - 1) { string[] ids = id[i]; ddl.ClearSelection(); ddl.Items.FindByValue(dt.Rows[i]["ResourceTypeID"].ToString()).Selected = true; //Assign the value from DataTable to the TextBox box2.Text = dt.Rows[i]["NoOfResources"].ToString().Trim(); //Set the Previous Selected Items on Each DropDownList on Postbacks ddl1.ClearSelection(); for (int j = 0; j < ids.Count(); j++) { for (int i1 = 0; i1 < ddl1.Items.Count; i1++) { if (ddl1.Items[i1].Value.Trim() == ids[j].ToString().Trim()) { ListBox ddl2 = (ListBox)GridviewResourceDetail.Rows[rowIndex].Cells[3].FindControl("SkillID"); ddl2.Items[i1].Selected = true; break; } } } //ddl1.Items.FindByValue(dt.Rows[i]["SkillID"].ToString()).Selected = true; box3.Text = dt.Rows[i]["StartDate"].ToString().Trim(); box4.Text = dt.Rows[i]["EndDate"].ToString().Trim(); } rowIndex++; } } } }
//string Mode = "Ins"; //Guid ScheduleId = Guid.Empty; //if (null == ViewState["ScheduleDetails"]) //{ // ViewState["ScheduleDetails"] = new Inspection().GetYearlyInspectionDetailsById(Guid.Empty); // ScheduleId = Guid.Empty; //} //if (null == ViewState["OfficeDetails"]) //{ // ViewState["OfficeDetails"] = new Inspection().GetOfficesByScheduleId(Guid.Empty); // ScheduleId = Guid.Empty; //} //if (FvYearlySchedule.CurrentMode == FormViewMode.Edit) //{ // ScheduleId = (Guid) FvYearlySchedule.DataKey["ScheduleId"]; // Mode = "Upd"; //} //GridView GvInspectionDetails = ((GridView) FvYearlySchedule.FindControl("GvInspectionDetails" + Mode)); //DataTable dtScheduleDetails = (DataTable) ViewState["ScheduleDetails"]; //DataTable dtOfficeDetails = (DataTable) ViewState["OfficeDetails"]; //DropDownList ddlMonth = ((DropDownList) FvYearlySchedule.FindControl("ddlMonth" + Mode)); //ListBox lstInspectingOffice = ((ListBox) FvYearlySchedule.FindControl("lstInspectingOffice" + Mode)); //TextBox txtDetailRemarks = ((TextBox) FvYearlySchedule.FindControl("txtDetailRemarks" + Mode)); ////object[] keys =new object [GvInspectionDetails.SelectedDataKey.Values.Count]; ////for (int i = 0; i < keys.Length; i++) ////{ //// keys[i] = GvInspectionDetails.SelectedDataKey.Values[i]; ////} ////DataRow dr = dtScheduleDetails.Rows.Find(keys); ////if (null == dr) ////{ //DataRow dr = dtScheduleDetails.NewRow(); //dr["DetailScheduleId"] = Guid.NewGuid(); //dr["ScheduleId"] = Guid.NewGuid(); //dr["Month"] = Convert.ToDecimal(ddlMonth.SelectedValue); //dr["Remarks"] = txtDetailRemarks.Text; ////dr["OfficeName"] = (lstInspectingOffice.SelectedItem.Text); //string lstbox = ""; //string lstboxComma=""; //foreach (ListItem lst in lstInspectingOffice.Items) //{ // if (lst.Selected) // { // lstbox += lst.Text + ","; // lstboxComma = lstbox.Substring(0, lstbox.Length - 1); // } // lstboxComma = lstbox.Substring(0, lstbox.Length - 1); //} //dr["OfficeName"] = lstboxComma; ////dr["OfficeName"] = lstbox; ////dr["OfficeName"] = lstbox; //// DataRow dr1 = dtOfficeDetails.NewRow(); //// dr1["OfficeId"] = new Guid(lstInspectingOffice.SelectedValue); //// DataTable dttbl = new DataTable(); //// dttbl.Columns.Add("DetailScheduleId", typeof(Guid)); //// dttbl.Columns.Add("ScheduleId", typeof(Guid)); //// dttbl.Columns.Add("Month", typeof(decimal)); //// dttbl.Columns.Add("Remarks", typeof(string)); //// dttbl.Columns.Add("OfficeId", typeof(Guid)); //// dttbl.Columns["DetailScheduleId"] = dr["DetailScheduleId"]; //// dttbl.Columns["ScheduleId"] = dr["ScheduleId"]; //// dttbl.Columns["Month"] = dr["Month"]; //// dttbl.Columns["Remarks"] = dr["Remarks"]; //// dttbl.Columns["OfficeId"] = dr1["OfficeId"]; ////DataSet ds = new DataSet(); ////ds.Tables.Add(dttbl); ////GvInspectionDetails.DataSource = ds.Tables[0]; ////GvInspectionDetails.DataBind(); //dtScheduleDetails.Rows.Add(dr); ////ddlMonth.SelectedIndex = -1; ////txtDetailRemarks.Text = ""; ////} ////((Button) FvYearlySchedule.FindControl("btnAddDetail" + Mode)).Visible = true; ////((Button) FvYearlySchedule.FindControl("btnUpdatePurchaseDetails" + Mode)).Visible = false; //ViewState["ScheduleDetails"] = dtScheduleDetails; //GvInspectionDetails.DataSource = (DataTable) ViewState["ScheduleDetails"]; //GvInspectionDetails.DataBind(); #endregion } protected void GvInspectionDetailsIns_SelectedIndexChanged(object sender, EventArgs e) { string Mode = String.Empty; switch (FvYearlySchedule.CurrentMode) { case FormViewMode.Edit: Mode = "Upd"; break; case FormViewMode.Insert: Mode = "Ins"; break; case FormViewMode.ReadOnly: Mode = "Itm"; break; default: break; } // Declare the varioables and get reference to the controls Guid ScheduleId = Guid.Empty; GridView gvInspectionDetails = ((GridView)FvYearlySchedule.FindControl("GvInspectionDetails" + Mode)); DropDownList ddlMonth = ((DropDownList)FvYearlySchedule.FindControl("ddlMonth" + Mode)); ListBox lstInspectingOffice = ((ListBox)FvYearlySchedule.FindControl("lstInspectingOffice" + Mode)); TextBox txtDetailRemarks = ((TextBox)FvYearlySchedule.FindControl("txtDetailRemarks" + Mode)); if (null == ViewState["ScheduleDetails"]) { ViewState["ScheduleDetails"] = new Inspection().GetYearlyInspectionDetailsById(Guid.Empty); ScheduleId = Guid.Empty; } if (FvYearlySchedule.CurrentMode == FormViewMode.Edit) { if (null == ViewState["SelectedOffices"]) { ViewState["SelectedOffices"] = new Inspection().GetMonthlyInspectionScheduleByDetailScheduleId((Guid)gvInspectionDetails.SelectedDataKey.Value); } ScheduleId = (Guid)FvYearlySchedule.DataKey["ScheduleId"]; } DataTable dtScheduleDetails = (DataTable)ViewState["ScheduleDetails"]; DataTable dtOfficeDetails = (DataTable)ViewState["SelectedOffices"]; object[] keys = { gvInspectionDetails.SelectedDataKey.Value }; DataRow drScheduleDetail = dtScheduleDetails.Rows.Find(keys); Guid DetailScheduleId = (Guid)drScheduleDetail["DetailScheduleId"]; if (null != drScheduleDetail) { ddlMonth.SelectedValue = Convert.ToString(drScheduleDetail["Month"]); txtDetailRemarks.Text = Convert.ToString(drScheduleDetail["Remarks"]); // Find and select each of the Offices lstInspectingOffice.ClearSelection(); foreach (DataRow row in dtOfficeDetails.Rows) { if (DetailScheduleId.Equals(row["DetailScheduleId"])) { lstInspectingOffice.Items.FindByValue(row["InspectingOfficeId"].ToString()).Selected = true; } } } // Show appropriate buttons ((Button)FvYearlySchedule.FindControl("btnAddInspectionDetail" + Mode)).Visible = false; ((Button)FvYearlySchedule.FindControl("btnUpdateInspectionDetail" + Mode)).Visible = true; }