I am trying to create an ASP.NET page to allow basic CRUD operations using Entity Framework. Using Telerik's RadListView, I have the following HTML:
And here is the code behind:
<telerik:RadListView ID="RadListView1" runat="server" OnNeedDataSource="RadListView1_NeedDataSource"><ItemTemplate> <table> <tr> <td>First Name: <%#Eval("FirstName")%> </td> </tr> <tr> <td> <asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="Edit" Width="70px"></asp:Button> </td> </tr> </table></ItemTemplate><EditItemTemplate> <table> <tr> <td>First Name: <asp:TextBox ID="txtFirstName" runat="server" Text='<%#Bind("FirstName")%>'></asp:TextBox> </td> </tr> <tr> <td> <asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName="Update" Width="70px"></asp:Button> </td> </tr> </table></EditItemTemplate>And here is the code behind:
protected void Page_Load(object sender, EventArgs e){ if (!Page.IsPostBack) { RadListView1.DataSource = GetData();
}}protected void RadListView1_NeedDataSource(object sender, Telerik.Web.UI.RadListViewNeedDataSourceEventArgs e){ RadListView1.DataSource = GetData();}private List<Person> GetData(){ using (BuildingAccessEntities ctx = new BuildingAccessEntities()) { var query = from a in ctx.People orderby a.FirstName select a; return query.ToList(); }}So far, this code properly displays the populated RadListView. When I click the Edit button, the RadListView switches to Edit mode and allows me to Edit the selected record; however, when I click the Update button to save the record, the changes are not saved.
I have not yet tried to see if inserts and deletes behave this same way.
I'm sure 2-way binding should be something very simple with the RadListView, but I am new to this and have not been able to find many examples to make this work other than by using data source controls (SqlDataSource, EntityDataSource, etc.).
Any assistance will be greatly appreciated!
