首页 新闻 会员 周边 捐助

DetailsView如何实现编辑功能,不用sqldatasource数据源

0
悬赏园豆:50

前台代码:

<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="false" HeaderText="Staff Detail"
                DataKeyNames="staffId" OnItemUpdated="DetailsView1_ItemUpdated" OnModeChanging="DetailsView1_ModeChanging"
                OnItemUpdating="DetailsView1_onItemUpdating" OnItemCommand="DetailsView1_onItemCommand">
                <HeaderStyle BackColor="BlueViolet" ForeColor="Black" Height="20px" />
                <Fields>
                    <asp:BoundField HeaderText="Staff ID" DataField="staffId" ReadOnly="true" />
                    <asp:BoundField HeaderText="User Name" DataField="userName" ReadOnly="true" />
                    <asp:BoundField HeaderText="First Name" DataField="firstName" ReadOnly="true" />
                    <asp:BoundField HeaderText="Last Name" DataField="LastName" ReadOnly="true" />
                    <asp:TemplateField HeaderText="Department">
                        <EditItemTemplate>
                            <asp:DropDownList ID="departmentlist" runat="server">
                            </asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Role">
                        <EditItemTemplate>
                            <asp:DropDownList ID="roledroplist" runat="server">
                            </asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Office">
                        <EditItemTemplate>
                            <asp:TextBox ID="office" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "roomName") %>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Phone Number">
                        <EditItemTemplate>
                            <asp:TextBox ID="phonenumber" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"phoneNumber")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Address">
                        <EditItemTemplate>
                            <asp:TextBox ID="address" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"address")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField ShowEditButton="true" />
                </Fields>
            </asp:DetailsView>

在cs 代码中怎么写?是写在ItemUpdating中吗

protected void DetailsView1_onItemUpdating(object sender,DetailsViewUpdateEventArgs e)
        {
         }

lovelifecai的主页 lovelifecai | 初学一级 | 园豆:100
提问于:2009-04-30 10:04
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册