protected void CargarLista(string pClContenedor, RadListBox pLista) { pLista.DataSource = vPlantilla.LST_CAMPOS.Where(w => w.CL_CONTENEDOR == pClContenedor).OrderBy(o => o.NO_ORDEN);//.Select(s => new RadListBoxItem(s.NB_CAMPO, s.ID_CAMPO.ToString())); pLista.DataValueField = "ID_CAMPO"; pLista.DataTextField = "NB_CAMPO"; pLista.DataBind(); }
/// <summary> /// 绑定数据 /// </summary> /// <param name="box"></param> /// <param name="dataSource"></param> /// <param name="textField"></param> /// <param name="valueField"></param> public static void BindData(RadListBox box, object dataSource, string textField, string valueField) { box.DataSource = dataSource; box.DataTextField = textField; box.DataValueField = valueField; box.DataBind(); }
/// <summary> /// /// </summary> /// <param name="rlbObject"></param> /// <param name="objSource"></param> /// <param name="valueColumn"></param> /// <param name="textColumn"></param> internal static void LlenarLB(RadListBox rlbObject, DataTable objSource, string valueColumn, string textColumn) { rlbObject.Items.Clear(); rlbObject.DataSource = objSource; rlbObject.DataValueField = valueColumn; rlbObject.DataTextField = textColumn; rlbObject.DataBind(); }
//NO LONGER BEING USED - So that all sites, regardless of office, are available to be assigned to a field trip protected void rddlOffice_SelectedIndexChanged(object source, EventArgs e) { RadDropDownList rddl = (RadDropDownList)source; GridEditFormInsertItem item = (GridEditFormInsertItem)rddl.NamingContainer; RadListBox rlb = (RadListBox)item.FindControl("rlbSitesStart2"); int office_id = Convert.ToInt32(rddl.SelectedValue); rlb.DataSource = Sites.Where(p => p.office_id == office_id); rlb.DataBind(); }
protected void gvChildCode_ItemDataBound(object sender, GridItemEventArgs e) { if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) { RadListBox chkbldepart = new RadListBox(); if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted) { GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item; TextBox txtChildCode = (TextBox)item.FindControl("txtChildCode"); chkbldepart = (RadListBox)item.FindControl("chkbldepart"); } if (e.Item is GridDataItem) { GridDataItem dataItem = e.Item as GridDataItem; LinkButton buttonEdit = dataItem["editColumn"].Controls[0] as LinkButton; LinkButton buttonDelete = dataItem["deleteColumn"].Controls[0] as LinkButton; //chkbldepart = dataItem["chkbldepart"].Controls[0] as RadListBox; } if (e.Item is GridEditFormItem && e.Item.IsInEditMode && e.Item.ItemIndex != -1) { string strExtType = gvChildCode.MasterTableView.DataKeyValues[e.Item.ItemIndex]["AAC_AgentCode"].ToString(); GridEditFormItem editedItem = (GridEditFormItem)e.Item; chkbldepart = (RadListBox)e.Item.FindControl("chkbldepart"); } DataSet dsDepartmentlist = new DataSet(); dsDepartmentlist = associatesBo.GetDepartment(advisorVo.advisorId); int departmentId = Convert.ToInt32(dsDepartmentlist.Tables[0].Rows[0]["AD_DepartmentId"].ToString()); DataTable dtBindAdvisor = new DataTable(); dtBindAdvisor = advisorStaffBo.GetUserRoleDepartmentWise(departmentId, advisorVo.advisorId); chkbldepart.DataSource = dtBindAdvisor; chkbldepart.DataTextField = dtBindAdvisor.Columns["AR_Role"].ToString(); chkbldepart.DataValueField = dtBindAdvisor.Columns["AR_RoleId"].ToString(); chkbldepart.DataBind(); if (e.Item.RowIndex != -1) { string roleIds = gvChildCode.MasterTableView.DataKeyValues[e.Item.ItemIndex]["RoleIds"].ToString(); string[] RoleIds = roleIds.Split(','); for (int i = 0; i < RoleIds.Length; i++) { foreach (RadListBoxItem li in chkbldepart.Items) { if (RoleIds[i] == li.Value.ToString()) { li.Checked = true; } } } } } }
/// <summary> /// 绑定数据 /// </summary> /// <param name="box"></param> /// <param name="dataSource">数据源</param> /// <param name="textfld">文本字段</param> /// <param name="valuefld">值字段</param> public static RadListBox BindData(this RadListBox box, object dataSource, string textfld, string valuefld) { if (box.SelectedIndex > -1) { box.ClearSelection(); } if (box.Items.Count > 0) { box.Items.Clear(); } box.DataSource = dataSource; box.DataTextField = textfld; box.DataValueField = valuefld; box.DataBind(); return(box); }
public static void RadListBoxDataBind(RadListBox lb, object obj, string method, string dataTextField, string dataValueField, params object[] parameters) { lb.Items.Clear(); Type type = obj.GetType(); MethodBase[] methodBases = type.GetMethods(); MethodBase methodBase = null; for (int i = 0; i < methodBases.Length; i++) { if (methodBases[i].Name.Equals(method) && methodBases[i].GetParameters().Length == parameters.Length) { methodBase = methodBases[i]; } } lb.DataSource = methodBase.Invoke(obj, parameters); lb.DataTextField = dataTextField; lb.DataValueField = dataValueField; lb.DataBind(); }
protected void rgJADuty_ItemDataBound(object sender, GridItemEventArgs e) { HideRefreshButton(e); GridItem gridItem = e.Item; //Issue Id: 28 //Author: Deepali Anuje //Date Fixed: 1/29/2012 //Description: Duty/KSA Screen of JA: Display Duty KSAs on This Screen if (gridItem.ItemType == GridItemType.Item || gridItem.ItemType == GridItemType.AlternatingItem) { RadListBox rdutyqual = gridItem.FindControl("radListDutyQual") as RadListBox; if (gridItem.DataItem is JobAnalysisDuty) { JobAnalysisDuty JADuty = gridItem.DataItem as JobAnalysisDuty; List <JobAnalysisDutyKSAFactor> qualList = JADuty.GetJobAnalysisDutyKSAFactorByJADutyID(); rdutyqual.DataSource = qualList; rdutyqual.DataBind(); rdutyqual.Visible = (qualList.Count > 0); } } }
protected void rgFieldTrips_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item.IsInEditMode) { GridEditableItem item = (GridEditableItem)e.Item; Panel pnlUpdate = (Panel)item.FindControl("pnlUpdate"); Panel pnlInsert = (Panel)item.FindControl("pnlInsert"); RadTextBox rtbTripName = (RadTextBox)item.FindControl("rtbTripName"); RadDropDownList rddlAssignedTo = (RadDropDownList)item.FindControl("rddlAssignedTo"); RadListBox rlbSitesStart = (RadListBox)item.FindControl("rlbSitesStart"); RadListBox rlbSitesEnd = (RadListBox)item.FindControl("rlbSitesEnd"); RadTextBox rtbTripName2 = (RadTextBox)item.FindControl("rtbTripName2"); RadDropDownList rddlOffice = (RadDropDownList)item.FindControl("rddlOffice"); RadDropDownList rddlAssignedTo2 = (RadDropDownList)item.FindControl("rddlAssignedTo2"); RadListBox rlbSitesStart2 = (RadListBox)item.FindControl("rlbSitesStart2"); RadListBox rlbSitesEnd2 = (RadListBox)item.FindControl("rlbSitesEnd2"); if (!(e.Item is IGridInsertItem)) { int trip_id = Convert.ToInt32(item.GetDataKeyValue("trip_id")); var currTrip = db.Trips.FirstOrDefault(p => p.trip_id == trip_id); rtbTripName.Text = currTrip.trip_nm; rddlAssignedTo.DataSource = Employees; rddlAssignedTo.DataBind(); rddlAssignedTo.SelectedValue = currTrip.user_id; rlbSitesStart.DataSource = Sites.Where(p => !currTrip.TripSites.Select(a => a.site_id).Contains(p.site_id)); rlbSitesStart.DataBind(); rlbSitesEnd.DataSource = currTrip.TripSites.Select(p => new { site_id = p.site_id, site_no_nm = p.Site.site_no + " " + p.Site.station_full_nm }).OrderBy(p => p.site_no_nm); rlbSitesEnd.DataBind(); pnlUpdate.Visible = true; pnlInsert.Visible = false; } else if ((e.Item is IGridInsertItem)) { rddlAssignedTo2.DataSource = Employees; rddlAssignedTo2.DataBind(); rddlOffice.DataSource = db.Offices.Where(p => p.wsc_id == WSCID).Select(p => new { office_id = p.office_id, office_nm = p.office_nm }).ToList(); rddlOffice.DataBind(); rlbSitesStart2.DataSource = Sites; rlbSitesStart2.DataBind(); pnlUpdate.Visible = false; pnlInsert.Visible = true; } } if (e.Item is GridDataItem) { GridDataItem item = (GridDataItem)e.Item; int trip_id = Convert.ToInt32(item.GetDataKeyValue("trip_id")); LinkButton lbDelete = (LinkButton)item.FindControl("lbDelete"); LinkButton lbViewSites = (LinkButton)item.FindControl("lbViewSites"); lbViewSites.OnClientClick = String.Format("openWin('{0}'); return false;", trip_id); lbDelete.OnClientClick = String.Format("ShowDeleteForm('{0}'); return false;", trip_id); if (Session["CanEdit"].ToString() == "false") { ImageButton ib = (ImageButton)item["EditCommandColumn"].Controls[0]; ib.Visible = false; LiteralControl lb = (LiteralControl)item["TemplateDeleteColumn"].Controls[0]; lb.Visible = false; } } }
/// <summary> /// Loads product type list boxes from sharepoint list. /// </summary> /// <param name="listBox">The list box.</param> /// <param name="listName">Name of the list.</param> /// <param name="columnName">Name of the column.</param> private void PopulateProdTypeLstBox(RadListBox listBox, string listName, string columnName) { DataTable dtListItems = null; objMossController = objFactory.GetServiceManager("MossService"); string strCamlQuery = "<OrderBy><FieldRef Name=\"" + columnName + "\"/></OrderBy>"; string strViewFields = @"<FieldRef Name='" + columnName + "'/>"; try { dtListItems = ((MOSSServiceManager)objMossController).ReadList(strCurrSiteUrl, listName, strCamlQuery, strViewFields); if((dtListItems != null) && (dtListItems.Rows.Count > 0)) { listBox.DataTextField = columnName; listBox.DataValueField = columnName;//dtListItems.Columns[columnName].ColumnName; listBox.DataSource = dtListItems; listBox.DataBind(); } } finally { if(dtListItems != null) { dtListItems.Dispose(); } } }
/// <summary> /// Loads the list box. /// </summary> /// <param name="objRadLstBxSource">The obj RAD LST bx source.</param> /// <param name="objRadLstBxDestination">The obj RAD LST bx destination.</param> private void LoadListOfContextSearch(RadListBox objRadLstBxSource, RadListBox objRadLstBxDestination) { Reorder objReorder = new Reorder(); XmlNodeList xmlNdLstSourceCol = null; XmlNodeList xmlNdLstDestinationCol = null; objReorder.SetSrcNDestNdLstForContextSearch(ddlRole.SelectedValue, radLstBxCategory.SelectedValue, ddlAssetType.SelectedValue, out xmlNdLstSourceCol, out xmlNdLstDestinationCol); objRadLstBxSource.Items.Clear(); if(xmlNdLstSourceCol != null && xmlNdLstSourceCol.Count > 0) { objRadLstBxSource.DataSource = xmlNdLstSourceCol; objRadLstBxSource.DataTextField = "value"; objRadLstBxSource.DataValueField = "value"; objRadLstBxSource.DataBind(); } objRadLstBxDestination.Items.Clear(); if(xmlNdLstDestinationCol != null && xmlNdLstDestinationCol.Count > 0) { objRadLstBxDestination.DataSource = xmlNdLstDestinationCol; objRadLstBxDestination.DataTextField = "value"; objRadLstBxDestination.DataValueField = "value"; objRadLstBxDestination.DataBind(); } }
/// <summary> /// Loads the list box. /// </summary> /// <param name="objRadLstBxSource">The obj RAD LST bx source.</param> /// <param name="objRadLstBxDestination">The obj RAD LST bx destination.</param> /// <param name="reponseXml">The reponse XML.</param> private void LoadListOfColumn(RadListBox objRadLstBxSource, RadListBox objRadLstBxDestination, XmlDocument reponseXml) { if(reponseXml != null) { Reorder objReorder = new Reorder(); XmlNodeList xmlNdLstSourceCol = null; XmlNodeList xmlNdLstDestinationCol = null; RadListBoxItem radLstBxItem = null; objReorder.SetSourceNDestinationItemList(ddlRole.SelectedValue, ddlSearchNames.SelectedValue, ddlAssetType.SelectedValue, reponseXml, out xmlNdLstSourceCol, out xmlNdLstDestinationCol); objRadLstBxSource.Items.Clear(); if(xmlNdLstSourceCol != null && xmlNdLstSourceCol.Count > 0) { objRadLstBxSource.DataSource = xmlNdLstSourceCol; objRadLstBxSource.DataTextField = "value"; objRadLstBxSource.DataValueField = "value"; objRadLstBxSource.DataBind(); } objRadLstBxDestination.Items.Clear(); if(xmlNdLstDestinationCol != null && xmlNdLstDestinationCol.Count > 0) { foreach(XmlNode xmlNodeCol in xmlNdLstDestinationCol) { radLstBxItem = new RadListBoxItem(xmlNodeCol.Attributes["name"].Value); objRadLstBxDestination.Items.Add(radLstBxItem); if(xmlNodeCol.Attributes["mandatory"].Value.ToLowerInvariant().Equals("true")) { radLstBxItem.Enabled = false; } } } } }
/// <summary> /// Loads the category. /// </summary> /// <param name="radListBx">The RAD list bx.</param> /// <param name="assetType">Type of the asset.</param> private void LoadCategory(RadListBox radListBx, string assetType) { Reorder objReorder = new Reorder(); XmlNodeList xmlNdLstSourceCol = null; xmlNdLstSourceCol = objReorder.GetNdLstForCategory(ddlRole.SelectedValue, assetType); radListBx.Items.Clear(); if(xmlNdLstSourceCol != null && xmlNdLstSourceCol.Count > 0) { radListBx.DataSource = xmlNdLstSourceCol; radListBx.DataTextField = "value"; radListBx.DataValueField = "value"; radListBx.DataBind(); } }
protected void CageTypesRadGrid_ItemDataBound(object sender, GridItemEventArgs e) { //if (e.Item is GridCommandItem) //{ // Button addButton = e.Item.FindControl("AddNewRecordButton") as Button; // addButton.Visible = false; // LinkButton lnkButton = (LinkButton)e.Item.FindControl("InitInsertButton"); // lnkButton.Visible = false; //} //Control cont = e.Item.NamingContainer; if (e.Item is GridDataItem && !e.Item.Expanded) { GridDataItem dataItem = e.Item as GridDataItem; string contactName = dataItem.GetDataKeyValue("cage_type_id").ToString(); Button button = dataItem["DeleteColumn"].Controls[0] as Button; button.Attributes["onclick"] = "return confirm('Are you sure you want to delete cage type " + contactName + "?')"; } if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode) { if (e.Item.ItemIndex < 0) { // Inserting Cage Type GridEditableItem editedItem = e.Item as GridEditableItem; ((RadTextBox)e.Item.FindControl("txtCageType")).Enabled = true; ((Label)(e.Item.FindControl("lblCageType"))).Visible = false; RadComboBox rcbCarriers = (RadComboBox)e.Item.FindControl("rcbCarriers"); RadComboBox rcbCarriers2 = (RadComboBox)e.Item.FindControl("rcbCarriers2"); CarrierDAO carrier = new CarrierDAO(); rcbCarriers.DataSource = carrier.GetCarriers(); rcbCarriers.DataTextField = "carrier_descr"; rcbCarriers.DataValueField = "carrier_id"; rcbCarriers.Items.Add(new RadComboBoxItem("Select Carrier")); rcbCarriers.DataBind(); RadComboBoxItem rcbItem = new RadComboBoxItem("Select Carrier", "-1"); rcbCarriers.Items.Add(rcbItem); rcbCarriers.SelectedValue = "-1"; rcbCarriers2.DataSource = carrier.GetCarriers(); rcbCarriers2.DataTextField = "carrier_descr"; rcbCarriers2.DataValueField = "carrier_id"; rcbCarriers2.Items.Add(new RadComboBoxItem("Select Carrier")); rcbCarriers2.DataBind(); rcbCarriers2.Items.Add(rcbItem); rcbCarriers2.SelectedValue = "-1"; RadComboBox rcbStoreDeliveryGroup = (RadComboBox)e.Item.FindControl("rcbStoreDeliveryGroup"); StoreDeliveryGroupDAO storeDeliveryGroup = new StoreDeliveryGroupDAO(); rcbStoreDeliveryGroup.DataSource = storeDeliveryGroup.GetStoreDeliveryGroups(); rcbStoreDeliveryGroup.DataTextField = "group_name"; rcbStoreDeliveryGroup.DataValueField = "group_id"; rcbStoreDeliveryGroup.DataBind(); RadComboBoxItem rcbItemStoreDeliveryGroup = new RadComboBoxItem("None", "-1"); rcbStoreDeliveryGroup.Items.Add(rcbItemStoreDeliveryGroup); rcbStoreDeliveryGroup.SelectedValue = "-1"; CagetypeDAO cagetypedao = new CagetypeDAO(); RadComboBox rcbCntryGrps = (RadComboBox)e.Item.FindControl("rcbCntryGrps"); rcbCntryGrps.DataSource = cagetypedao.GetCountryGroups(); rcbCntryGrps.DataTextField = "country_group_descr"; rcbCntryGrps.DataValueField = "country_group_id"; rcbCntryGrps.DataBind(); RadComboBoxItem rcbitemCntryGrp = new RadComboBoxItem("All", "-1"); rcbCntryGrps.Items.Add(rcbitemCntryGrp); rcbCntryGrps.SelectedValue = "-1"; } else { // Editing Cage Type GridEditableItem editedItem = e.Item as GridEditableItem; string cagetype = editedItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cage_type_id"].ToString(); DataRowView row = (DataRowView)e.Item.DataItem; ((Label)(e.Item.FindControl("lblCageType"))).Visible = true; ((Label)(e.Item.FindControl("lblCageType"))).Text = cagetype; ((RadTextBox)(e.Item.FindControl("txtCageType"))).Visible = false; ((RadTextBox)e.Item.FindControl("txtCageTypeDescr")).Text = (string)row.Row["cage_type_descr"]; string despatchable_ind = (string)row.Row["despatchable_ind"]; if (despatchable_ind == "T") { ((CheckBox)e.Item.FindControl("cbDespatchableInd")).Checked = true; } else { ((CheckBox)e.Item.FindControl("cbDespatchableInd")).Checked = false; } RadComboBox rcbCarriers = (RadComboBox)e.Item.FindControl("rcbCarriers"); CarrierDAO carrier = new CarrierDAO(); rcbCarriers.DataSource = carrier.GetCarriers(); rcbCarriers.DataTextField = "carrier_descr"; rcbCarriers.DataValueField = "carrier_id"; rcbCarriers.SelectedValue = (string)row.Row["carrier_id"]; rcbCarriers.DataBind(); RadComboBox rcbCarriers2 = (RadComboBox)e.Item.FindControl("rcbCarriers2"); rcbCarriers2.DataSource = carrier.GetCarriers(); rcbCarriers2.DataTextField = "carrier_descr"; rcbCarriers2.DataValueField = "carrier_id"; rcbCarriers2.SelectedValue = (string)row.Row["carrier_id"]; rcbCarriers2.DataBind(); RadComboBox rcbStoreDeliveryGroup = (RadComboBox)e.Item.FindControl("rcbStoreDeliveryGroup"); StoreDeliveryGroupDAO storeDeliveryGroup = new StoreDeliveryGroupDAO(); rcbStoreDeliveryGroup.DataSource = storeDeliveryGroup.GetStoreDeliveryGroups(); rcbStoreDeliveryGroup.DataTextField = "group_name"; rcbStoreDeliveryGroup.DataValueField = "group_id"; rcbStoreDeliveryGroup.DataBind(); RadComboBoxItem rcbItemStoreDeliveryGrp = new RadComboBoxItem("None", "-1"); rcbStoreDeliveryGroup.Items.Add(rcbItemStoreDeliveryGrp); if (row.Row["sd_group_id"] is System.DBNull) { rcbStoreDeliveryGroup.SelectedValue = "-1"; } else { Int64 stgroupid = (Int64)row.Row["sd_group_id"]; rcbStoreDeliveryGroup.SelectedValue = stgroupid.ToString(); } CagetypeDAO cagetypedao = new CagetypeDAO(); RadComboBox rcbCntryGrps = (RadComboBox)e.Item.FindControl("rcbCntryGrps"); rcbCntryGrps.DataSource = cagetypedao.GetCountryGroups(); rcbCntryGrps.DataTextField = "country_group_descr"; rcbCntryGrps.DataValueField = "country_group_id"; rcbCntryGrps.DataBind(); RadComboBoxItem rcbitemCntryGrp = new RadComboBoxItem("All", "-1"); rcbCntryGrps.Items.Add(rcbitemCntryGrp); if (row.Row["country_group_id"] is System.DBNull) { rcbCntryGrps.SelectedValue = "-1"; } else { rcbCntryGrps.SelectedValue = (string)row.Row["country_group_id"]; } RadListBox rlbFrom = (RadListBox)e.Item.FindControl("RadListBoxFrom"); RadListBox rlbTo = (RadListBox)e.Item.FindControl("RadListBoxTo"); CagetypeServiceDAO cts = new CagetypeServiceDAO(); rlbFrom.DataSource = cts.GetAvailableServices(cagetype).Tables[0]; rlbTo.DataSource = cts.GetCageServices(cagetype).Tables[0]; rlbFrom.DataBind(); rlbTo.DataBind(); } } }