使用 RadControls 插入数据时出现错误
错误:
无法更新 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查主键,检查您的表 ClientFeedBack 是否定义了主键。
Check for the primary key, check if you table ClientFeedBack has primary key defined or not.