I'm having a hard time trying to setup the new aspnet identity using webforms.
Currently I'm trying to setup an admin page in order to modify a roles after they've been created.
So far I have this in my aspx page. It's the gridview that displays the roles.
<asp:GridView ID="gvRoles" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowCommand="gvRoles_RowCommand"
OnRowEditing="gvRoles_RowEditing" OnPageIndexChanging="gvRoles_PageIndexChanging" OnRowCancelingEdit="gvRoles_RowCancelingEdit"
OnRowDeleting="gvRoles_RowDeleting" OnRowUpdating="gvRoles_RowUpdating" AutoGenerateColumns="false" >
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
<asp:TemplateField HeaderText="Id">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblIDEdit" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbName" runat="server" Text='<%#Eval("Name") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
And in the gvRoles_RowUpdating event I have the following code.
protected void gvRoles_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
context.Entry(role).State = System.Data.Entity.EntityState.Modified;
context.SaveChanges();
gvRoles.EditIndex = -1;
LoadData();
}
but for the life of me I can't figure out how to update role with the changed data in context.Entry(role).State.
Any insight would be appreciated.