C# datagridview的文本将消失

C# datagridview的文本将消失,c#,datagridview,telerik,telerik-grid,datagridviewcombobox,C#,Datagridview,Telerik,Telerik Grid,Datagridviewcombobox,我在我的项目中使用telerik控件(数据网格视图)。但当我想在数据网格中添加新行时,前几行(bindingSourceService.DataSource=dtservice,bindingSourceUnit.DataSource=dtunit)的文本就会消失。 我的datagridview有3个组合框列。 怎么了?请帮帮我 我的代码: public void FactorLoad(object sender, EventArgs e) { try

我在我的项目中使用telerik控件(数据网格视图)。但当我想在数据网格中添加新行时,前几行(bindingSourceService.DataSource=dtservice,bindingSourceUnit.DataSource=dtunit)的文本就会消失。 我的datagridview有3个组合框列。 怎么了?请帮帮我

我的代码:

public void FactorLoad(object sender, EventArgs e)
        {
            try
            {
                var cb = new CategoriBll();
               DataTable dtcategori = cb.GetAllDataCategori();
               bindingSourceCategouri.DataSource = dtcategori;
            }
            catch (Exception ex)
            {
               ExceptionkeeperBll.LogFileWrite(ex);
            }
}
   private void DataGridViewFactorCellValueChanged(object sender, GridViewCellEventArgs e)
        {
            try
            {
                var row = DataGridViewFactor.CurrentRow;
                if ((row != null) && (row.Cells[0].IsCurrent))
                {
                    var categoryId = Convert.ToInt32(DataGridViewFactor.CurrentRow.Cells[0].Value);
                    var sb = new CategoriOptionBll();
                    DataTable dtservice = sb.ServiceGetById(categoryId);
                    bindingSourceService.DataSource = dtservice;
                }
                if ((row != null) && (row.Cells[1].IsCurrent))
                {
                    var serviceId = Convert.ToInt32(DataGridViewFactor.CurrentRow.Cells[1].Value);
                    var cbi = new CostBll();
                    var dtunit = cbi.CostById(serviceId);
                    bindingSourceUnit.DataSource = dtunit;
                }
            }
            catch (Exception ex)
            {
                ExceptionkeeperBll.LogFileWrite(ex);
            }
        }

        private void DataGridViewFactorCellEditorInitialized(object sender, GridViewCellEventArgs e)
        {
            try
            {
                var row = DataGridViewFactor.CurrentRow;
                if ((row != null) && (row.Cells[0].IsCurrent))
                {
                    var categoryId = Convert.ToInt32(DataGridViewFactor.CurrentRow.Cells[0].Value);
                    var sb = new CategoriOptionBll();
                    DataTable dtservice = sb.ServiceGetById(categoryId);
                    bindingSourceService.DataSource = dtservice;
                }
                if ((row != null) && (row.Cells[1].IsCurrent))
                {
                    var serviceId = Convert.ToInt32(DataGridViewFactor.CurrentRow.Cells[1].Value);
                    var cbi = new CostBll();
                    var dtunit = cbi.CostById(serviceId);
                    bindingSourceUnit.DataSource = dtunit;
                }
            }
            catch (Exception ex)
            {
                ExceptionkeeperBll.LogFileWrite(ex);
            }
        }

它将消失,因为数据源中只有1个值。尝试向数据源添加值,而不是指定单个值。

首先将数据插入数据库,然后将此数据源重新加载到网格:)我如何才能做到这一点?请你解释一下好吗?