ASPX无法从gridview进行方法更新

时间:2011-09-12 09:56:23

标签: c# .net asp.net

我遇到麻烦,当我在我的aspx页面中的gridview中按更新时,它不会使用该方法。这是我的代码的一部分:

.aspx的:

<asp:GridView ID="FBGrid" runat="server"  
  AutoGenerateColumns="False" AutoGenerateEditButton="True"  
  OnRowEditing="FBGrid_EditRecord" OnRowCancelingEdit="FBGrid_RowCancelingEdit"  
  CellSpacing="10" OnRowUpdating="FBGrid_UpdateRecord"
  ShowFooter="True" 
  ItemStyle-HorizontalAlign="Right"  
  Height="159px" Width="695px">

然后在我的aspx.cs中,方法如下:

protected void FBGrid_UpdateRecord(object sender, GridViewUpdateEventArgs e)
{
    int x = e.RowIndex;

    Label txtName = FBGrid.Rows[x].FindControl("BankName") as Label;
    Label txtRef = FBGrid.Rows[x].FindControl("NumberofReferencesRequired") as Label;
    Label txtItems = FBGrid.Rows[x].FindControl("MaximumNumberOfItems") as Label;
    Label txtID = FBGrid.Rows[x].FindControl("BankID") as Label;


    int a = Convert.ToInt32(txtID.Text);
    String b = txtName.Text;
    int c = Convert.ToInt32(txtItems.Text);
    int d = Convert.ToInt32(txtRef.Text);

    ForeignBankDetails FB = new ForeignBankDetails(a, b, c, d);
    BusinessLayerHandler.UpdateForeignBanks(FB);
    FillFBGrid();            
}

我已经设置了一个断点,发现这个方法正在被完全跳过。

<asp:RegularExpressionValidator style="position: relative; left: -55px;" 
  id="RegularExpressionValidator4" runat="server" ErrorMessage="RegularExpressionValidator" 
  ForeColor="Red" ControlToValidate="ReferenceChoice" ValidationExpression="(^\d*\.?\d*[0-9]+\d*$)|(^[0-9]+\d*\.\d*$)">
    Invalid Numbers
</asp:RegularExpressionValidator>
<asp:RangeValidator runat="server" id="RangeValidator3" controltovalidate="ReferenceChoice"
  type="Double" minimumvalue="0" maximumvalue="999999999999999" ForeColor="Red"
  errormessage="Invalid Range"/>

1 个答案:

答案 0 :(得分:0)

嗨,问题是在同一页面内有验证,因此页面卡住了