简体   繁体   中英

Edit one field in DetailsView

I am using a DetailsView in ASP.net. And I would like that you can edit one field at a time. Is this possible?

Here is my DetailsView

<asp:DetailsView ID="dvProfiel" runat="server" 
    DataSourceID="odsUserByUserName" AutoGenerateRows="False">
    <Fields>
        <asp:TemplateField HeaderText="ID">
            <ItemTemplate>
                <asp:Label ID="lblKlantenNummer" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>


        <asp:TemplateField HeaderText="First Name">
            <ItemTemplate>
                <asp:Label ID="lblFirstName" runat="server" Text='<%# Eval("FirstName") %>'></asp:Label>
                <asp:LinkButton ID="lbEditFirstName" CommandName="Edit" runat="server">Edit</asp:LinkButton>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="txtFirstName" Text='<%# Bind("FirstName") %>' runat="server"></asp:TextBox>
                <asp:LinkButton ID="lbUpdateFirstName" CommandName="Update" runat="server">Update</asp:LinkButton>
                <asp:LinkButton ID="lbCancelFirstName" CommandName="Cancel" runat="server">Cancel</asp:LinkButton>
            </EditItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Last Name">
            <ItemTemplate>
                <asp:Label ID="lblLastName" runat="server" Text='<%# Eval("LastName") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="txtLastName" Text='<%# Bind("LastName") %>' runat="server"></asp:TextBox>
                <asp:LinkButton ID="lbUpdateLastName" CommandName="Update" runat="server">Update</asp:LinkButton>
                <asp:LinkButton ID="lbCancelLastName" CommandName="Cancel" runat="server">Cancel</asp:LinkButton>
            </EditItemTemplate>
        </asp:TemplateField>

    </Fields>
</asp:DetailsView>

When I click to edit the First Name, the field Last Name als goes into Edit mode. I just want the field where I clicked the edit button that goes in Edit mode.

I hope you understand me.

Thank you, Vincent

Here is the link that might help you.

http://www.daniweb.com/forums/thread207014.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM