Click here to Skip to main content
15,922,584 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Development Issue : BC30311: Value of type 'System.Web.UI.Control' cannot be converted to 'System.Windows.Forms.TextBox'. Pin
jkirkerx5-Nov-11 17:28
professionaljkirkerx5-Nov-11 17:28 
Questiongridview control Pin
dcof2-Nov-11 8:53
dcof2-Nov-11 8:53 
AnswerRe: gridview control Pin
Anurag Gandhi3-Nov-11 0:30
professionalAnurag Gandhi3-Nov-11 0:30 
QuestionWord Automation Pin
padmanabhan N1-Nov-11 19:56
padmanabhan N1-Nov-11 19:56 
Questionfpassing asp.net field Pin
dcof1-Nov-11 12:36
dcof1-Nov-11 12:36 
AnswerRe: fpassing asp.net field Pin
Not Active1-Nov-11 13:51
mentorNot Active1-Nov-11 13:51 
GeneralRe: fpassing asp.net field Pin
dcof1-Nov-11 17:47
dcof1-Nov-11 17:47 
GeneralRe: fpassing asp.net field Pin
Brij1-Nov-11 21:48
mentorBrij1-Nov-11 21:48 
GeneralRe: fpassing asp.net field Pin
Not Active2-Nov-11 2:17
mentorNot Active2-Nov-11 2:17 
Questiontable control asp.net 2010 Pin
classy_dog1-Nov-11 9:27
classy_dog1-Nov-11 9:27 
AnswerRe: table control asp.net 2010 Pin
Dennis E White1-Nov-11 12:01
professionalDennis E White1-Nov-11 12:01 
QuestionAsync Report MVC3 Pin
eddieangel1-Nov-11 7:00
eddieangel1-Nov-11 7:00 
QuestionNeeded Code of changing dropdownlist Pin
Raghu1630-Oct-11 19:28
Raghu1630-Oct-11 19:28 
AnswerRe: Needed Code of changing dropdownlist Pin
Anurag Gandhi30-Oct-11 22:47
professionalAnurag Gandhi30-Oct-11 22:47 
QuestionCan't see my site's flash in an iframe tag Pin
benams30-Oct-11 6:37
benams30-Oct-11 6:37 
QuestionSubmitChanges is not working Pin
classy_dog29-Oct-11 8:17
classy_dog29-Oct-11 8:17 
I am working on a C#.net 2010 application I just wrote. Right now I am getting the error

'Cannot add an entity that already exists'. I get that error on the following line of code: attPlanDataContext.SubmitChanges();

I am trying to write to a table that has one to many rows that relate to the main table. When I try to add the second row to the table, that is when the error occurs.

I am hoping you can suggest what I need to change to fix this error. The following is the code that is affected by this error:

[^] protected void submitbutton(object sender, EventArgs e)
{

if (!Page.IsPostBack)
return;

CustomerDataContext attDataContext = new CustomerDataContext();
Customer att = null;
att = new Customer();
InsertCustomer(att);
attDataContext.Customer.InsertOnSubmit(att);
attDataContext.SubmitChanges();
CustomerDataContext attPlanDataContext = new CustomerDataContext();
Plan attplan = null;
attplan = new Plan();
InsertPlans(attplan, att, attPlanDataContext);

}
protected void InsertCustomer(Customer att)
{
// fills in data here
}
protected void InsertPlans(Plan attplan,Customer att, CustomerDataContext attPlanDataContext)
{


for (int i = 0; i < ChkBoxLstPlan.Items.Count; i++)
{

if (ChkBoxLstPlan.Items[i].Selected)
{
attplan.Att_id = att.Att_id;
attplan.Number = ChkBoxLstPlan.Items[i].Value.Substring(0, 5);
// Update the database
attPlanDataContext.Plans.InsertOnSubmit(attplan);
attPlanDataContext.SubmitChanges();
}
}

}
[^]
AnswerRe: SubmitChanges is not working Pin
Richard MacCutchan29-Oct-11 22:38
mveRichard MacCutchan29-Oct-11 22:38 
GeneralRe: SubmitChanges is not working Pin
classy_dog30-Oct-11 11:06
classy_dog30-Oct-11 11:06 
GeneralRe: SubmitChanges is not working Pin
Richard MacCutchan30-Oct-11 23:36
mveRichard MacCutchan30-Oct-11 23:36 
AnswerRe: SubmitChanges is not working Pin
phil.o29-Oct-11 23:54
professionalphil.o29-Oct-11 23:54 
GeneralRe: SubmitChanges is not working Pin
classy_dog30-Oct-11 11:08
classy_dog30-Oct-11 11:08 
GeneralRe: SubmitChanges is not working Pin
phil.o30-Oct-11 23:18
professionalphil.o30-Oct-11 23:18 
AnswerRe: SubmitChanges is not working Pin
oujeboland30-Oct-11 7:03
oujeboland30-Oct-11 7:03 
GeneralRe: SubmitChanges is not working Pin
classy_dog30-Oct-11 11:09
classy_dog30-Oct-11 11:09 
Questionvalidation control final? Pin
classy_dog29-Oct-11 8:05
classy_dog29-Oct-11 8:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.