使用 RadControls 插入数据时出现错误

发布于 2024-12-01 02:09:36 字数 1466 浏览 0 评论 0原文

错误:

无法更新 EntitySet“ClientFeedBack”,因为它具有 DefiningQuery,且 元素中不存在支持当前操作的 元素.

代码:

protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
    ProTrakEntities1 objEntity = new ProTrakEntities1(); 
    TextBox txtTitle = DetailsView1.FindControl("txtTask") as TextBox;
    RadComboBox cmbStatus = DetailsView1.FindControl("cmbStatus") as RadComboBox;  

    RadComboBox cmbTaskType = DetailsView1.FindControl("cmbTasktype") as RadComboBox;  
    RadComboBox cmbTaskPriorty = DetailsView1.FindControl("cmbPriority") as RadComboBox;

    string Description = (DetailsView1.FindControl("RadEditor1") as RadEditor).Content;

    ClientFeedBack objResource = new ClientFeedBack();
    objResource.Title = txtTitle.Text;
    objResource.Description = Description;

    objResource.TaskPriorityID = Convert.ToInt32(cmbTaskPriorty.SelectedValue);
    objResource.TaskTypeID = Convert.ToInt32(cmbTaskType.SelectedValue);

    objEntity.AddToClientFeedBacks(objResource);
    objEntity.SaveChanges();

    DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
    ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind('navigateToInserted');", true);
}

我的表名称是ClientFeedBack

Error:

Unable to update the EntitySet 'ClientFeedBack' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.

Code:

protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
    ProTrakEntities1 objEntity = new ProTrakEntities1(); 
    TextBox txtTitle = DetailsView1.FindControl("txtTask") as TextBox;
    RadComboBox cmbStatus = DetailsView1.FindControl("cmbStatus") as RadComboBox;  

    RadComboBox cmbTaskType = DetailsView1.FindControl("cmbTasktype") as RadComboBox;  
    RadComboBox cmbTaskPriorty = DetailsView1.FindControl("cmbPriority") as RadComboBox;

    string Description = (DetailsView1.FindControl("RadEditor1") as RadEditor).Content;

    ClientFeedBack objResource = new ClientFeedBack();
    objResource.Title = txtTitle.Text;
    objResource.Description = Description;

    objResource.TaskPriorityID = Convert.ToInt32(cmbTaskPriorty.SelectedValue);
    objResource.TaskTypeID = Convert.ToInt32(cmbTaskType.SelectedValue);

    objEntity.AddToClientFeedBacks(objResource);
    objEntity.SaveChanges();

    DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
    ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind('navigateToInserted');", true);
}

My table name is ClientFeedBack.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲娇萝莉攻 2024-12-08 02:09:36

检查主键,检查您的表 ClientFeedBack 是否定义了主键。

Check for the primary key, check if you table ClientFeedBack has primary key defined or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文