日期:2014-05-17  浏览次数:20483 次

在gridview中编辑记录,如何利用ObjectDataSource更新
在gridview中编辑记录,如何利用ObjectDataSource更新

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        DataSourceID="ObjectDataSource1" AllowSorting="True" GridLines="None" 
                        DataKeyNames="ID">
                        <Columns>
                            <asp:TemplateField HeaderText="序号">
                                <ItemTemplate>
                                    <%# Container.DataItemIndex + 1%>
                                </ItemTemplate>
                                <HeaderStyle CssClass="first" Width="50px" />
                                <ItemStyle CssClass="first" Width="50px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="单位名称" SortExpression="UnitName">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("UnitName") %>'></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
                                        ErrorMessage="*" ForeColor="Red">*</asp:RequiredFieldValidator>
      &nb