Skip to main content
 首页 » 编程设计

c#之无法将类型 'double' 隐式转换为 'RadTextBox'

2024年02月13日13linjiqin

我有一个小问题,我这里有一个 RadTextBox,它应该在数据库中接收浮点值,日期类型也是浮点,所以现在如果我想绑定(bind) RadTextBox,总会出现这个奇怪的错误

Error 4 Cannot implicitly convert type 'double' to 'Telerik.Web.UI.RadTextBox'

我需要解析还是其他?

我的代码

private void bindData() 
{ 
    this.cbActive.Checked = this.paramBR.GetActive(); 
    this.rtbCode.Text = this.paramBR.Code; 
    this.rtbDescription.Text = this.paramBR.Description; 
    this.rtbHourlyRate = this.paramBR.HourlyRate; 
} 
 
BillingRate br = ctx.BillingRate.Where(yx => yx.BillingRateId == this.paramBR.BillingRateId).FirstOrDefault(); 
if (br == null) 
{ 
    br = new BillingRate(); 
    newEntity = true; 
} 
br.Code = this.rtbCode.Text; 
br.Description = this.rtbDescription.Text; 
br.SetActive(this.cbActive.Checked); 
br.HourlyRate = this.rtbHourlyRate.Text; 
br.CreatedDate = DateTime.Now; 
br.CreatedBy = this.User.UserId; 

请您参考如下方法:

你应该使用 .Text最后一行中的属性并使用 .ToString()将 double 转换为 string 的方法。

this.rtbHourlyRate.Text = this.paramBR.HourlyRate.ToString();