Hi All,
I have a scenario in my project. I'm using Entity Framework 4 with Asp.Net, C#.
Problem statement:
There are several sections and relations among tables. The gets populated and saved in one go. But I also have two list view controls called Panel Members and Deliverables. Each of list view control are dynamic in nature and almost having similar features. There is a server side Button control i.e. "Add Member". This allows user to add a new row in listview control. The use fills up the columns and click on "Save" button within listview. This should allow user to add another row using "Add Member" button. Though I have used the following code:
protected void lvMembers_ItemInserting(object sender, ListViewInsertEventArgs e) { Country.PanelMembers.Add(new PanelMembers() { MemberName=((TextBox)e.Item.FindControl("txtMemberName")).Text, MemberDept=((TextBox)e.Item.FindControl("txtMemberDept")).Text, ... } lvMembers.InsertItemPosition=InsertItemPosition.None; btnAddMember.Visible=true; BindListViewWithMembers(); } private void BindListViewWithMembers() { lvMembers.DataSource=Country.PanelMembers; lvMembers.DataBind(); btnAddMembers.Visible=true; }
Though Country is parent entity and PanelMembers are child entity and the values will not be saved until user enters all panel members e.g. 1 to 10. The listview always shows only one row as soon as I click on "Add Member" button. I know the reason but don't have solution. It is happening because I'm binding listview with Country.PanelMember which is not yet saved finally in database.
Please do help me.