老问题了,为什么在gridview编辑提交时,总是得不到新值,得到的总是原来的值。
在网上搜索了很久,该注意的地方都注意到了,如将绑定放在!IsPostBack里,但还是得不到新值。我在gridview里用的都是模板列,以下是源码,麻烦大家帮我看看吧,我已经折腾了2天了。
ASPX页面:
<asp:GridView Width="98%" ID="myGV" runat="server" AutoGenerateColumns="false" OnPageIndexChanging="PageChanging"
OnRowCommand="RowCommand" OnSorting="Sorting" OnRowDataBound="RowDataBound" OnRowCancelingEdit="myGV_RowCancelingEdit"
OnRowEditing="myGV_RowEditing" OnRowUpdating="myGV_RowUpdating" ShowFooter="true">
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" ItemStyle-HorizontalAlign="center"
ReadOnly="True">
<ItemStyle BackColor="#EFEFEF" Width="40px" />
</asp:BoundField>
<asp:TemplateField HeaderText="标签" SortExpression="tags" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<%# Eval("tags") %>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<EditItemTemplate>
<asp:TextBox SkinID="TextBox_Single" runat="server" Width="180px" Font-Size="9pt"
Text='<%# Eval("tags") %>' ID="Textbox211" NAME="Textbox211" />
</EditItemTemplate>
<FooterTemplate>
<div align="center" style="margin-left: 10pt">
<asp:LinkButton runat="server" OnClick="addNewRow" Text="<img src=images/add.gif border=0> 新建"
ID="Linkbutton1" NAME="Linkbutton1" />
</div>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="分类" SortExpression="category" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<%# Eval("category")%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<EditItemTemplate>
<asp:HiddenField ID="hdCategory" runat="server" Value='<%# Eval("category") %>' />
<asp:DropDownList ID="dropCategory" runat="server" Width="120px" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="删除" ShowHeader="False">
<ItemStyle HorizontalAlign="center" />
<ItemTemplate>
<a