0
<asp:GridView Width="300px" RowStyle-Height="20px" HeaderStyle-Height="25px" DataKeyNames="Id" ID="bankAccounts_List" CssClass="table" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:TemplateField HeaderText="Sorting Handle" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" >
<ItemTemplate>
<span class="handle"><img src="../Images/sortingHandler.jpg" height="10" /></span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Account Number">
<ItemTemplate>
<asp:TextBox ID="grd_txtbankAccountNumber" Width="150" onblur="return OnBlurGridTextbox(this);" BorderStyle="None" BackColor="White" style="text-align:left;" runat="server" Text='<%# Eval("AccountNo") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Priority" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" >
<ItemTemplate>
<asp:TextBox ID="grd_txtPriority" Width="100" BorderStyle="None" BackColor="White" runat="server" style="text-align:center"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" >
<ItemTemplate>
<asp:LinkButton runat="server" ID="grd_linkbutton" OnClientClick="return EditGridButton(this)">Edit</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Id" >
<HeaderStyle CssClass="hiddencol" />
<ItemStyle CssClass="hiddencol" />
<ItemTemplate>
<asp:Label ID="grd_lblId" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="btnSaveBankInformation" runat="server" Text="<%$Resources:Strings,save%>"
OnClick="btnSaveBankInformation_Click" />
protected void btnSaveBankInformation_Click(object sender, EventArgs e)
{
TextBox txtBankAccountNumber = bankAccounts_List.Rows[i].Cells[GetColumnIndexByName(bankAccounts_List.Rows[i], "Account Number")].FindControl("grd_txtbankAccountNumber") as TextBox;
}
以往我在任何文本框的變化是什麼,在保存按鈕,我總是很舊的綁定文本框的值不是我剛剛進入新的價值。 請幫助我。是的我沒有綁定GridBack上的回發再次使用!IsPostBack
ASP:GridView的文本框舊值回發
附註:你不需要在單元格上使用FindControl。使用'bankAccounts_List.Rows [i] .FindControl(「grd_txtbankAccountNumber」)'就足夠了,因爲這行是'NamingContainer'。 –
什麼是「OnBlurGridTextbox」?無論如何,即使你聲稱使用'!IsPostBack',我們也想看到它;} –
你是否在做這個'if(!IsPostBack) { }' @TimSchmelter表示 – KhawajaAtteeq