update linq related table

微笑、不失礼 提交于 2019-12-02 09:17:40

问题


I have a User table like (Id,Name,UserAddresId) and UserAddress table like(Id,AddressOne) with a FormView Control and i want to have an update command in it. Here's my form:

    <asp:FormView ID="orderInfolst" runat="server" DataKeyNames="Id" DataSourceID="OrderSrc">
    <ItemTemplate>
     Name:
     <asp:Label ID="namelbl" runat="server" Text='<%# Eval("Name") %>' /> 
     User Address One 
     <asp:Label ID="namelbl" runat="server" Text='<%# Eval("UserAddresses.AddressOne") %>' />  
 <asp:Button ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="ویرایش" />    
</ItemTemplate>
    <EditTemplate>
     Name:
     <asp:TextBox ID="namelbl" runat="server" Text='<%# Bind("Name") %>' /> 
     User Address One; 
     <asp:TextBox ID="namelbl" runat="server" Text='<%# Bind("UserAddresses.AddressOne") %>' />
 <asp:Button ID="UpdateButton" runat="server"   CausesValidation="True" CommandName="Update"  Text="ویرایش شود" />
                          &nbsp;<asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="لغو شود" />

    </EditTemplate>

and in server I have a handler for ItemUpdated Event like this:

if (e.Exception == null)
{
    Resultlbl.Text = "update successfully ";
}
else 
{
    Resultlbl.Text = e.Exception.Message;
}    

I get the Update Successfully message. so Name filed updated but AddressOne in related Table not updated!!! what is wrong here?

来源:https://stackoverflow.com/questions/17058601/update-linq-related-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!