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

  • 问题

  • <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> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("UnitName") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="排序" SortExpression="SortIndex"> <EditItemTemplate> <asp:TextBox ID="TextBox2" Width="30px" runat="server" Text='<%# Bind("SortIndex") %>'></asp:TextBox> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="TextBox2" ErrorMessage="*" ForeColor="Red" Operator="DataTypeCheck" Type="Integer">*</asp:CompareValidator> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("SortIndex") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:CommandField ShowEditButton="True" /> </Columns> <RowStyle CssClass="row" /> </asp:GridView> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="UnitInfo" UpdateMethod="UpdateUnitInfo">  <UpdateParameters>
                        <asp:Parameter Name="unitName" Type="String" />
                        <asp:Parameter Name="sortIndex" Type="String" />
                        <asp:Parameter Name="id" Type="String" />
                    </UpdateParameters>

    </asp:ObjectDataSource>


    如何将gridview中文本框中内容和objectdatasource中参数对应起来呢?<UpdateParameters>内参数该如何设定?
    2013年2月17日 0:29

答案