Ejemplo n.º 1
0
 //updating the datasource in accordance to the users selection from the
 //dropdown list
 protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (dataSource != null)
     {
         PropertyInfo property      = dataSource.GetType().GetProperty(column.Text);
         string       selectedValue = ((DropDownList)sender).SelectedValue;
         object       oValue        = NullFinder.Parse(selectedValue, property.PropertyType);
         property.SetValue(dataSource, oValue, null);
     }
 }
Ejemplo n.º 2
0
        //when the value of the field is changed (by the user), and is valid
        //the handler updates the associated property of the datasource.
        protected void txt_TextChanged(object sender, EventArgs e)
        {
            PropertyInfo property = dataSource.GetType().GetProperty(column.Text);
            TextBox      txt      = (TextBox)sender;

            try
            {
                object oValue;
                if (txt.Text.Trim() == string.Empty)
                {
                    oValue = NullFinder.GetNullValue(column.DataType);
                }
                else
                {
                    oValue = NullFinder.Parse(txt.Text, property.PropertyType);
                }
                property.SetValue(dataSource, oValue, null);
            }
            catch (Exception)
            {
                txt_DataBinding(txt, null);
            }
        }