protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack && _typeName!=null)
     {
         lstTypes.Items.Clear();
         TypeRefBiz biz = new TypeRefBiz();
         DS_TypeRef.DListDataTable dt = biz.GetValidListValue(_typeName);
         foreach (DS_TypeRef.DListRow row in dt.Rows)
         {
             ListItem item = new ListItem(row.listTitle, row.listValue);
             lstTypes.Items.Add(item);
         }
         if (lstTypes.Items.Count > 0 && _defaultValue!="nodefault")
         {
             ListItem item = new ListItem(_noSelectPrompt, _defaultValue);
             lstTypes.Items.Insert(0, item);
         }
     }
 }
Exemple #2
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (_isListChanged)
        {
            lstTypes.Items.Clear();
            string tn = TypeName;
            if (tn != null)
            {
                TypeRefBiz biz = new TypeRefBiz();
                DS_TypeRef.DListDataTable dt = biz.GetValidListValue(tn);
                foreach (DS_TypeRef.DListRow row in dt.Rows)
                {
                    ListItem item = new ListItem(row.listTitle, row.listValue);
                    lstTypes.Items.Add(item);
                }
                if (lstTypes.Items.Count > 0)
                {
                    ListItem item = new ListItem("--Please Select--", "0");
                    lstTypes.Items.Insert(0, item);
                }
            }
        }

        if (_isSelectChanged || lstTypes.Items.Count>0)
        {
            int i;
            for (i = 0; i < lstTypes.Items.Count; i++)
            {
                if (lstTypes.Items[i].Value == _selectedValue)
                {
                    lstTypes.Items[i].Selected = true;
                    break;
                }
            }
            if (i > lstTypes.Items.Count)
            {
                lstTypes.SelectedIndex = 0;
            }
        }
    }