private void AddressDropdownDataBind(object sender, EventArgs e) { var ddl = (DropDownList)sender; var container = (IDataItemContainer)ddl.NamingContainer; try { ddl.Visible = visibleStatus.DefaultIfEmpty(true).First(); if (ddl.Visible) { var usr = UserController.GetCurrentUserInfo(); var addressData = new AddressData(usr.UserID.ToString("")); if (ddl.Attributes["blank"] != null) { var li = new ListItem(); li.Text = ddl.Attributes["blank"]; li.Value = "-1"; ddl.Items.Add(li); ddl.Attributes.Remove("blank"); } var addrlist = addressData.GetAddressList(); foreach (var tItem in addrlist) { var itemtext = tItem.GetXmlProperty("genxml/textbox/firstname") + "," + tItem.GetXmlProperty("genxml/textbox/lastname") + "," + tItem.GetXmlProperty("genxml/textbox/unit") + "," + tItem.GetXmlProperty("genxml/textbox/street") + "," + tItem.GetXmlProperty("genxml/textbox/city"); if (ddl.Attributes["template"] != null) { itemtext = ""; var xpathList = ddl.Attributes["template"].Split(','); foreach (var xp in xpathList) { itemtext += "," + tItem.GetXmlProperty(xp); } } var datatext = ""; if (ddl.Attributes["data"] != null) { var xpathList = ddl.Attributes["data"].Split(','); foreach (var xp in xpathList) { datatext += "," + tItem.GetXmlProperty(xp).Replace(","," "); } } var datavalue = ""; if (ddl.Attributes["datavalue"] != null) datavalue += ddl.Attributes["datavalue"]; var idx = tItem.GetXmlProperty("genxml/hidden/index"); if (ddl.Items.FindByValue(idx) == null) { var li = new ListItem(); li.Text = itemtext.TrimStart(','); li.Value = idx; li.Attributes.Add("data", datatext.TrimStart(',')); li.Attributes.Add("datavalue", datavalue); ddl.Items.Add(li); } } } } catch (Exception) { ddl.Visible = false; } }