This is a migrated thread and some comments may be shown as answers.

Web User Control Components Self Resetting

1 Answer 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stevan Gajic
Top achievements
Rank 1
Stevan Gajic asked on 26 May 2010, 01:38 PM
I've got a RadGrid inside a RadMultiPageView all inside a RadAjaxPanel, for editing the grid I used a WUC which contains various RadComboBoxes and RadTextBoxes including Numerics. My problem is that on postback, the server side code executes, but the value selected isn't used. Instead the original value is being executed. I've tried removing all the behaviors from the code execept those that actually build the component with the same results. The grid uses an ODS for the data source. The dropdown boxes are built procedurally on page load.

The grid declaration:
                <telerik:RadGrid ID="rgBacteriaWarning" runat="server" ondetailtabledatabind="rgGrid_DetailTableDataBind" onitemupdated="rgBacteria_ItemUpdated">  
                </telerik:RadGrid> 

Code that builds the grid:
                ObjectDataSource ods = new ObjectDataSource();  
                ods.SelectMethod = "GetHoldingTests";  
                ods.SelectParameters.Add("guid", guid.ToString());  
                ods.SelectParameters.Add("type", Enum.GetName(typeof(ValidationType), ValidationType.Warning));  
                ods.TypeName = "CTI.CTCM.Data.Samples.BacteriaODS";  
 
                rgBacteriaWarning.Columns.Clear();  
                rgBacteriaWarning.Skin = SKINNAME;  
                rgBacteriaWarning.AllowAutomaticDeletes = true;  
                rgBacteriaWarning.AllowAutomaticUpdates = true;  
                rgBacteriaWarning.AllowPaging = true;  
                rgBacteriaWarning.AllowSorting = true;  
                rgBacteriaWarning.AutoGenerateColumns = false;  
                rgBacteriaWarning.DataSource = ods.Select();  
                rgBacteriaWarning.MasterTableView.EditFormSettings.EditFormType = GridEditFormType.WebUserControl;  
                rgBacteriaWarning.MasterTableView.EditFormSettings.UserControlName = "VerifyBacteria.ascx";  
                rgBacteriaWarning.MasterTableView.EditMode = GridEditMode.EditForms;  
 
                rgBacteriaWarning.Columns.Add(new GridEditCommandColumn());  
                rgBacteriaWarning.Columns.Add(gb1);  
                rgBacteriaWarning.Columns.Add(gb2);  
                rgBacteriaWarning.Columns.Add(gb3);  
                rgBacteriaWarning.Columns.Add(gb4);  
                rgBacteriaWarning.Columns.Add(gb5);  
                rgBacteriaWarning.Columns.Add(gb6);  
                rgBacteriaWarning.Columns.Add(gb7);  
                rgBacteriaWarning.Columns.Add(gb8);  
                rgBacteriaWarning.Columns.Add(gb9);  
                rgBacteriaWarning.Columns.Add(gb10);  
                rgBacteriaWarning.Columns.Add(gb11);  
                rgBacteriaWarning.Columns.Add(gb12);  
                rgBacteriaWarning.Columns.Add(gb13);  
                rgBacteriaWarning.Columns.Add(gb14);  
                rgBacteriaWarning.Columns.Add(gb15);  
                rgBacteriaWarning.Columns.Add(gb16);  
 
                if (rgBacteriaWarning.MasterTableView.DetailTables.Count < 1)  
                {  
                    GridTableView gtvWarning = new GridTableView(rgBacteriaWarning);  
                    rgBacteriaWarning.MasterTableView.DetailTables.Add(gtvWarning);  
                    gtvWarning.DataMember = "warningDetails";  
                }  
 
                rgBacteriaWarning.DataBind();  

The WIP WUC:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VerifyBacteria.ascx.cs" Inherits="CTI.CTCM.UI.Upload.VerifyBacteria" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<table border="0" cellspacing="0" cellpadding="0" width="100%">  
    <tr> 
        <td align="right">Field Name :</td> 
        <td align="left">  
            <telerik:RadComboBox ID="rcbField" runat="server" onselectedindexchanged="rcbField_SelectedIndexChanged" NoWrap="True"></telerik:RadComboBox> 
        </td> 
        <td align="right">Monitoring Method :</td> 
        <td align="left">  
            <telerik:RadTextBox ID="rtbMonitoringMethod" runat="server"   
                ontextchanged="rtbMonitoringMethod_TextChanged"></telerik:RadTextBox> 
            <asp:Label ID="lblMonitoringMethod" runat="server"></asp:Label> 
        </td> 
    </tr> 
    <tr> 
        <td align="right">Lease Name :</td> 
        <td align="left">  
            <telerik:RadComboBox ID="rcbLease" runat="server" onselectedindexchanged="rcbLease_SelectedIndexChanged" NoWrap="True"></telerik:RadComboBox> 
        </td> 
        <td align="right">Chloride Percent Range :</td> 
        <td align="left">  
            <telerik:RadNumericTextBox ID="rntbChloridePercentRange" runat="server" ontextchanged="rntbChloridePercentRange_TextChanged"></telerik:RadNumericTextBox> 
            <asp:Label ID="lblChloridePctRange" runat="server"></asp:Label> 
        </td> 
    </tr> 
    <tr> 
        <td align="right">Location Name :</td> 
        <td align="left">  
            <telerik:RadComboBox ID="rcbLocation" runat="server" onselectedindexchanged="rcbLocation_SelectedIndexChanged" NoWrap="True"></telerik:RadComboBox> 
        </td> 
        <td align="right">Media Type :</td> 
        <td align="left">  
            <telerik:RadTextBox ID="rtbMediaType" runat="server" ontextchanged="rtbMediaType_TextChanged"></telerik:RadTextBox> 
            <asp:Label ID="lblMediaType" runat="server"></asp:Label> 
        </td> 
    </tr> 
    <tr> 
        <td align="right">SMI :</td> 
        <td align="left">  
            <telerik:RadComboBox ID="rcbSMI" runat="server" NoWrap="True"   
                onselectedindexchanged="rcbSMI_SelectedIndexChanged"></telerik:RadComboBox> 
            <asp:Label ID="lblSMI" runat="server" ForeColor="Red"></asp:Label> 
        </td> 
        <td align="right">Days Incubated :</td> 
        <td align="left">  
            <telerik:RadNumericTextBox ID="rntbDaysIncubated" runat="server" ontextchanged="rntbDaysIncubated_TextChanged"></telerik:RadNumericTextBox> 
            <asp:Label ID="lblDaysIncubated" runat="server"></asp:Label> 
        </td> 
    </tr> 
    <tr> 
        <td align="right">Date :</td> 
        <td align="left">  
            <telerik:RadDatePicker ID="rdpDate" runat="server" onselecteddatechanged="rdpDate_SelectedDateChanged"></telerik:RadDatePicker> 
            <asp:Label ID="lblDate" runat="server" ForeColor="Red"></asp:Label> 
        </td> 
        <td align="right">Bottles Shot :</td> 
        <td align="left">  
            <telerik:RadNumericTextBox ID="rntbBottlesShot" runat="Server" ontextchanged="rntbBottlesShot_TextChanged"></telerik:RadNumericTextBox> 
            <asp:Label ID="lblBottlesShot" runat="server"></asp:Label> 
        </td> 
    </tr> 
    <tr> 
        <td align="right">Bacteria Aerobe :</td> 
        <td align="left">  
            <telerik:RadComboBox ID="rcbBacteriaAerobe" runat="server" onselectedindexchanged="rcbBacteriaAerobe_SelectedIndexChanged"></telerik:RadComboBox> 
            <asp:Label ID="lblBacteriaAerobe" runat="server"></asp:Label> 
        </td> 
        <td align="right">Bottles Positive :</td> 
        <td align="left">  
            <telerik:RadNumericTextBox ID="rntbBottlesPositive" runat="server" ontextchanged="rntbBottlesPositive_TextChanged"></telerik:RadNumericTextBox> 
            <asp:Label ID="lblBottlesPositive" runat="server"></asp:Label> 
        </td> 
    </tr> 
    <tr> 
        <td align="right">Bacteria Type :</td> 
        <td align="left">  
            <telerik:RadComboBox ID="rcbBacteriaType" runat="server" onselectedindexchanged="rcbBacteriaType_SelectedIndexChanged"></telerik:RadComboBox> 
            <asp:Label ID="lblBacteriaType" runat="server"></asp:Label> 
        </td> 
        <td align="right">Colony Count :</td> 
        <td align="left">  
            <telerik:RadNumericTextBox ID="rntbColonyCount" runat="server"   
                ontextchanged="rntbColonyCount_TextChanged"></telerik:RadNumericTextBox> 
            <asp:Label ID="lblColonyCount" runat="server"></asp:Label> 
        </td> 
    </tr> 
    <tr> 
        <td colspan="4" align="left">  
            Comments :<br /> 
            <telerik:RadTextBox ID="rtbComments" runat="server" Width="100%" Height="100px"   
                ontextchanged="rtbComments_TextChanged"></telerik:RadTextBox> 
        </td> 
    </tr> 
</table> 
 

The WIP Backend Code for the WUC:
namespace CTI.CTCM.UI.Upload  
{  
    public partial class VerifyBacteria : System.Web.UI.UserControl  
    {  
        private const string SKINNAME = "Vista";  
 
        private BacteriaHoldingSample _dataItem = null;  
 
        public object DataItem  
        {  
            get { return _dataItem; }  
            set { _dataItem = (BacteriaHoldingSample)value; }  
        }  
 
        protected void Page_Load(object sender, EventArgs e)  
        {  
            rcbField.Skin = SKINNAME;  
            rcbLease.Skin = SKINNAME;  
            rcbLocation.Skin = SKINNAME;  
            rcbSMI.Skin = SKINNAME;  
            rdpDate.Skin = SKINNAME;  
            rcbBacteriaAerobe.Skin = SKINNAME;  
            rcbBacteriaType.Skin = SKINNAME;  
            rtbMonitoringMethod.Skin = SKINNAME;  
            rntbChloridePercentRange.Skin = SKINNAME;  
            rtbMediaType.Skin = SKINNAME;  
            rntbDaysIncubated.Skin = SKINNAME;  
            rntbBottlesShot.Skin = SKINNAME;  
            rntbBottlesPositive.Skin = SKINNAME;  
            rntbColonyCount.Skin = SKINNAME;  
            rtbComments.Skin = SKINNAME;  
 
            BuildRcbField();  
 
            rdpDate.AutoPostBack = true;  
            try 
            {  
                rdpDate.SelectedDate = Convert.ToDateTime(_dataItem.Date);  
            }  
            catch (System.Exception ex)  
            {  
                lblDate.Text = " * Please select a valid date.";  
            }  
 
            BuildBacteriaAerobe();  
            BuildBacteriaType();  
 
            rtbMonitoringMethod.AutoPostBack = true;  
            if (_dataItem.MonitoringMethod == string.Empty)  
                lblMonitoringMethod.Text = " * No monitoring method entered.";  
            else 
                rtbMonitoringMethod.Text = _dataItem.MonitoringMethod;  
 
            BuildChloridePercentRange();  
 
            rtbMediaType.AutoPostBack = true;  
            if (_dataItem.MediaType == string.Empty)  
                lblMediaType.Text = " * No media type entered.";  
            else 
                rtbMediaType.Text = _dataItem.MediaType;  
 
            BuildDaysIncubated();  
            BuildBottlesShot();  
            BuildBottlesPositive();  
            BuildColonyCount();  
 
            rtbComments.AutoPostBack = true;  
            rtbComments.Text = _dataItem.Comments;  
        }  
 
        private void BuildRcbField()  
        {  
            Boolean validField = false;  
 
            if (rcbField.Items.Count < 1)  
            {  
                SMIDataWrapper sdw = new SMIDataWrapper();  
                SqlDataReader sdr = sdw.GetFieldInfo();  
                //rcbField.Items.Clear();  
 
                while (sdr.Read())  
                {  
                    string fieldName = sdr["FieldName"].ToString();  
                    string value = sdr["FieldID"].ToString();  
                    RadComboBoxItem item = new RadComboBoxItem(fieldName, value);  
                    rcbField.Items.Add(item);  
 
                    if (fieldName == _dataItem.Field)  
                        validField = true;  
                }  
 
                sdr.Close();  
                rcbField.AutoPostBack = true;  
            }  
            else 
                validField = true;  
 
            if (validField)  
            {  
                int validIndex = rcbField.Items.FindItemByText(_dataItem.Field).Index;  
                rcbField.SelectedIndex = validIndex;  
                rcbLease.Enabled = true;  
                rcbLocation.Enabled = false;  
                rcbSMI.Enabled = false;  
                rcbField_SelectedIndexChanged(nullnull);  
            }  
            else 
            {  
                rcbLease.Enabled = false;  
                rcbLocation.Enabled = false;  
                rcbSMI.Enabled = false;  
                lblSMI.Text = " * There is no valid field name selected.\n";  
            }  
        }  
 
        private void BuildBacteriaAerobe()  
        {  
            rcbBacteriaAerobe.Items.Clear();  
 
            foreach (string type in Enum.GetNames(typeof(BacteriaAerobe)))  
            {  
                RadComboBoxItem item = new RadComboBoxItem(type);  
                rcbBacteriaAerobe.Items.Add(item);  
            }  
 
            rcbBacteriaAerobe.AutoPostBack = true;  
 
            switch (_dataItem.BacteriaAerobe)  
            {  
                case "Aerobic":  
                    rcbBacteriaAerobe.SelectedIndex = rcbBacteriaAerobe.FindItemIndexByText("Aerobic");  
                    break;  
                case "Anaerobic":  
                    rcbBacteriaAerobe.SelectedIndex = rcbBacteriaAerobe.FindItemIndexByText("Anaerobic");  
                    break;  
                default:  
                    rcbBacteriaAerobe.SelectedIndex = rcbBacteriaAerobe.FindItemIndexByText("NA");  
                    lblBacteriaAerobe.Text = " * The bacteria can only be aerobic or anaerobic.";  
                    break;  
            }  
        }  
 
        private void BuildBacteriaType()  
        {  
            rcbBacteriaType.Items.Clear();  
 
            foreach (string type in Enum.GetNames(typeof(BacteriaType)))  
            {  
                RadComboBoxItem item = new RadComboBoxItem(type);  
                rcbBacteriaType.Items.Add(item);  
            }  
 
            rcbBacteriaType.AutoPostBack = true;  
 
            switch (_dataItem.BacteriaType)  
            {  
                case "SRB":  
                    rcbBacteriaType.SelectedIndex = rcbBacteriaType.FindItemIndexByText("SRB");  
                    break;  
                case "APB":  
                    rcbBacteriaType.SelectedIndex = rcbBacteriaType.FindItemIndexByText("APB");  
                    break;  
                case "SRBAPB":  
                    rcbBacteriaType.SelectedIndex = rcbBacteriaType.FindItemIndexByText("SRBAPB");  
                    break;  
                case "None":  
                    rcbBacteriaType.SelectedIndex = rcbBacteriaType.FindItemIndexByText("None");  
                    break;  
                default:  
                    rcbBacteriaType.SelectedIndex = rcbBacteriaType.FindItemIndexByText("NA");  
                    lblBacteriaType.Text = " * The bacteria type can only be SRB, APB, SRBAPB, or none.";  
                    break;  
            }  
        }  
 
        private void BuildChloridePercentRange()  
        {  
            rntbChloridePercentRange.AutoPostBack = true;  
            rntbChloridePercentRange.MaxValue = 100;  
            rntbChloridePercentRange.MinValue = 0;  
            rntbChloridePercentRange.NumberFormat.DecimalDigits = 1;  
            rntbChloridePercentRange.ShowSpinButtons = true;  
 
            try 
            {  
                if (_dataItem.ChloridePctRange == string.Empty)  
                    lblChloridePctRange.Text = " * No data in chloride percent range.";  
 
                int cpr = Convert.ToInt32(_dataItem.ChloridePctRange);  
 
                if (cpr > 100)  
                {  
                    lblChloridePctRange.Text = " * Chloride percent range is over 100%.";  
                    rntbChloridePercentRange.Value = 100;  
                }  
                else if (cpr < 0)  
                {  
                    lblChloridePctRange.Text = " * Chloride percent range cannot be negative.";  
                    rntbChloridePercentRange.Value = 0;  
                }  
                else 
                    rntbChloridePercentRange.Value = cpr;  
            }  
            catch (System.Exception ex)  
            {  
                if (_dataItem.ChloridePctRange == string.Empty)  
                    lblChloridePctRange.Text = " * No data in chloride percent range.";  
                else 
                    lblChloridePctRange.Text = " * Incorrect data type in chloride percent range.";  
            }  
        }  
 
        private void BuildDaysIncubated()  
        {  
            rntbDaysIncubated.AutoPostBack = true;  
            rntbDaysIncubated.MinValue = 0;  
            rntbDaysIncubated.NumberFormat.DecimalDigits = 0;  
            rntbDaysIncubated.ShowSpinButtons = true;  
 
            try 
            {  
                if (_dataItem.DaysIncubated == string.Empty)  
                    lblDaysIncubated.Text = " * No data in days incubated.";  
                else 
                    rntbDaysIncubated.Value = Convert.ToInt32(_dataItem.DaysIncubated);  
            }  
            catch (System.Exception ex)  
            {  
                lblDaysIncubated.Text = " * Incorrect data type in days incubated.";  
            }  
        }  
 
        private void BuildBottlesShot()  
        {  
            rntbBottlesShot.AutoPostBack = true;  
            rntbBottlesShot.MinValue = 0;  
            rntbBottlesShot.NumberFormat.DecimalDigits = 0;  
            rntbBottlesShot.ShowSpinButtons = true;  
 
            try 
            {  
                if (_dataItem.BottlesShot == string.Empty)  
                    lblBottlesShot.Text = " * No data in bottles shot.";  
                else 
                    rntbBottlesShot.Value = Convert.ToInt32(_dataItem.BottlesShot);  
            }  
            catch (System.Exception ex)  
            {  
                lblBottlesShot.Text = " * Incorrect data type in bottles shot.";  
            }  
        }  
 
        private void BuildBottlesPositive()  
        {  
            rntbBottlesPositive.AutoPostBack = true;  
            rntbBottlesPositive.MinValue = 0;  
            rntbBottlesPositive.NumberFormat.DecimalDigits = 0;  
            rntbBottlesPositive.ShowSpinButtons = true;  
 
            try 
            {  
                if (_dataItem.BottlesPositive == string.Empty)  
                    lblBottlesPositive.Text = " * No data in bottles positive.";  
                else 
                    rntbBottlesPositive.Value = Convert.ToInt32(_dataItem.BottlesPositive);  
 
                if (rntbBottlesPositive.Value > rntbBottlesShot.Value)  
                    lblBottlesPositive.Text = " * Bottles positive can't be higher than bottles shot.";  
            }  
            catch (System.Exception ex)  
            {  
                rntbBottlesPositive.Text = " * Incorrect data type in bottles positive.";  
            }  
        }  
 
        private void BuildColonyCount()  
        {  
            rntbColonyCount.AutoPostBack = true;  
            rntbColonyCount.MinValue = 0;  
            rntbColonyCount.NumberFormat.DecimalDigits = 0;  
            rntbColonyCount.NumberFormat.GroupSeparator = ",";  
 
            try 
            {  
                if (_dataItem.ColonyCount == string.Empty)  
                    lblColonyCount.Text = " * No data in colony count.";  
                else 
                    rntbColonyCount.Value = Convert.ToInt32(_dataItem.ColonyCount);  
 
                UInt64 calulatedColony = CTI.CTCM.Equations.BacteriaEq.CalcColonyCount(Convert.ToInt32(rntbBottlesPositive.Value));  
 
                if (Convert.ToDouble(calulatedColony) != rntbColonyCount.Value)  
                    lblColonyCount.Text = " * Calculated colony count is " + calulatedColony.ToString() + ".";  
            }  
            catch (System.Exception ex)  
            {  
                lblColonyCount.Text = " * Incorrect data type in colony count.";  
            }  
        }  
 
        protected void rcbField_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
            _dataItem.Field = rcbField.SelectedItem.Text;  
 
            SMIDataWrapper sdw = new SMIDataWrapper();  
            SqlDataReader sdr = sdw.GetFieldInfo();  
 
            sdr = sdw.GetLeaseInfo(Convert.ToInt32(rcbField.SelectedValue));  
            Boolean validLease = false;  
            rcbLease.Items.Clear();  
 
            while(sdr.Read())  
            {  
                string leaseName = sdr["LeaseName"].ToString();  
                string value = sdr["LeaseID"].ToString();  
                RadComboBoxItem item = new RadComboBoxItem(leaseName, value);  
                rcbLease.Items.Add(item);  
 
                if (leaseName == _dataItem.Lease)  
                    validLease = true;  
            }  
 
            sdr.Close();  
 
            rcbLease.AutoPostBack = true;  
 
            if(validLease)  
            {  
                int validIndex = rcbLease.Items.FindItemByText(_dataItem.Lease).Index;  
                rcbLease.SelectedIndex = validIndex;  
                rcbLocation.Enabled = true;  
                rcbSMI.Enabled = false;  
                rcbLease_SelectedIndexChanged(nullnull);  
            }  
            else 
            {  
                rcbLocation.Enabled = false;  
                rcbSMI.Enabled = false;  
                lblSMI.Text = " * There is no valid lease selected.\n";  
            }  
        }  
 
        protected void rcbLease_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
            _dataItem.Lease = rcbLease.SelectedItem.Text;  
 
            SMIDataWrapper sdw = new SMIDataWrapper();  
            SqlDataReader sdr = sdw.GetLocationInfo(Convert.ToInt32(rcbLease.SelectedValue));  
            Boolean validLocation = false;  
            rcbLocation.Items.Clear();  
 
            while(sdr.Read())  
            {  
                string locationName = sdr["LocationName"].ToString();  
                string locationID = sdr["LocationID"].ToString();  
                RadComboBoxItem item = new RadComboBoxItem(locationName, locationID);  
                rcbLocation.Items.Add(item);  
 
                if (locationName == _dataItem.Location)  
                    validLocation = true;  
            }  
 
            sdr.Close();  
            rcbLocation.AutoPostBack = true;  
 
            if (validLocation)  
            {  
                int validIndex = rcbLocation.Items.FindItemByText(_dataItem.Location).Index;  
                rcbLocation.SelectedIndex = validIndex;  
                rcbSMI.Enabled = true;  
                rcbLocation_SelectedIndexChanged(nullnull);  
            }  
            else 
            {  
                rcbSMI.Enabled = false;  
                lblSMI.Text = " * There is no valid location selected.";  
            }  
        }  
 
        protected void rcbLocation_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
            _dataItem.Location = rcbLocation.SelectedItem.Text;  
 
            rcbSMI.Enabled = true;  
            SMIDataWrapper sdw = new SMIDataWrapper();  
            SqlDataReader sdr = sdw.GetSMIInfo(Convert.ToInt32(rcbLocation.SelectedValue));  
            Boolean validSMI = false;  
            rcbSMI.Items.Clear();  
 
            while(sdr.Read())  
            {  
                string SMIName = sdr["SMI"].ToString();  
                RadComboBoxItem item = new RadComboBoxItem(SMIName);  
                rcbSMI.Items.Add(item);  
 
                if (SMIName == _dataItem.SMI)  
                    validSMI = true;  
            }  
 
            sdr.Close();  
            rcbSMI.AutoPostBack = true;  
 
            if (validSMI)  
            {  
                rcbSMI.SelectedIndex = rcbSMI.FindItemIndexByText(_dataItem.SMI);  
                rcbSMI_SelectedIndexChanged(nullnull);  
            }  
            else 
                lblSMI.Text = " * There is no valid SMI selected.";  
        }  
 
        protected void rcbSMI_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
            _dataItem.SMI = rcbSMI.SelectedItem.Text;  
            lblSMI.Text = "";  
        }  
 
        protected void rdpDate_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)  
        {  
            _dataItem.Date = rdpDate.SelectedDate.ToString();  
            lblDate.Text = "";  
        }  
 
        protected void rcbBacteriaAerobe_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
            _dataItem.BacteriaAerobe = rcbBacteriaAerobe.SelectedItem.Text;  
 
            if (_dataItem.BacteriaAerobe == "Aerobic" || _dataItem.BacteriaAerobe == "Anaerobic")  
                lblBacteriaAerobe.Text = "";  
            else 
                lblBacteriaAerobe.Text = " * The bacteria can only be aerobic or anaerobic.";  
        }  
 
        protected void rcbBacteriaType_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
            _dataItem.BacteriaType = rcbBacteriaType.SelectedItem.Text;  
 
            if (_dataItem.BacteriaType == "SRB" || _dataItem.BacteriaType == "APB" ||  
                _dataItem.BacteriaType == "SRBAPB" || _dataItem.BacteriaType == "None")  
                lblBacteriaType.Text = "";  
            else 
                lblBacteriaType.Text = " * The bacteria type can only be SRB, APB, SRBAPB, or none.";  
        }  
 
        protected void rtbMonitoringMethod_TextChanged(object sender, EventArgs e)  
        {  
            if (rtbMonitoringMethod.Text == string.Empty)  
                lblMonitoringMethod.Text = " * No monitoring method entered.";  
            else 
            {  
                lblMonitoringMethod.Text = "";  
                _dataItem.MonitoringMethod = rtbMonitoringMethod.Text;  
            }  
        }  
 
        protected void rntbChloridePercentRange_TextChanged(object sender, EventArgs e)  
        {  
            _dataItem.ChloridePctRange = rntbChloridePercentRange.Value.ToString();  
            lblChloridePctRange.Text = "";  
        }  
 
        protected void rtbMediaType_TextChanged(object sender, EventArgs e)  
        {  
            if (rtbMediaType.Text == string.Empty)  
                lblMediaType.Text = " * No media type entered.";  
            else 
            {  
                lblMediaType.Text = "";  
                _dataItem.MediaType = rtbMediaType.Text;  
            }  
        }  
 
        protected void rntbDaysIncubated_TextChanged(object sender, EventArgs e)  
        {  
            _dataItem.DaysIncubated = rntbDaysIncubated.Value.ToString();  
            lblDaysIncubated.Text = "";  
        }  
 
        protected void rntbBottlesShot_TextChanged(object sender, EventArgs e)  
        {  
            _dataItem.BottlesShot = rntbBottlesShot.Value.ToString();  
            lblBottlesShot.Text = "";  
        }  
 
        protected void rntbBottlesPositive_TextChanged(object sender, EventArgs e)  
        {  
            _dataItem.BottlesPositive = rntbBottlesPositive.Value.ToString();  
 
            if (rntbBottlesPositive.Value > rntbBottlesShot.Value)  
                lblBottlesPositive.Text = " * Bottles positive can't be higher than bottles shot.";  
            else 
                lblBottlesPositive.Text = "";  
 
            UInt64 calulatedColony = CTI.CTCM.Equations.BacteriaEq.CalcColonyCount(Convert.ToInt32(rntbBottlesPositive.Value));  
 
            if (Convert.ToDouble(calulatedColony) != rntbColonyCount.Value)  
                lblColonyCount.Text = " * Calculated colony count is " + calulatedColony.ToString() + ".";  
        }  
 
        protected void rntbColonyCount_TextChanged(object sender, EventArgs e)  
        {  
            _dataItem.ColonyCount = rntbColonyCount.Value.ToString();  
 
            UInt64 calulatedColony = CTI.CTCM.Equations.BacteriaEq.CalcColonyCount(Convert.ToInt32(rntbBottlesPositive.Value));  
 
            if (Convert.ToDouble(calulatedColony) != rntbColonyCount.Value)  
                lblColonyCount.Text = " * Calculated colony count is " + calulatedColony.ToString() + ".";  
            else 
                lblColonyCount.Text = "";  
        }  
 
        protected void rtbComments_TextChanged(object sender, EventArgs e)  
        {  
            _dataItem.Comments = rtbComments.Text;  
        }  
    }  

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 01 Jun 2010, 09:20 AM
Hi Stevan,

I suggest that you handle the DataBinding event of the user control and there bind the comboboxes and set their selected values. Find the below article for more information:

http://www.telerik.com/help/aspnet-ajax/grdcustomeditforms.html

Regards,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Stevan Gajic
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or