Home > Net >  The gridview in asp.net, please how to get the old value in the rowupdating event?
The gridview in asp.net, please how to get the old value in the rowupdating event?

Time:09-24

I want to be after click rowediting events, the gridview into edit mode, the textbox input validation, if the input value is equal to the old, is not to search the nuptial operation, if the new value is not equal to the old value, repeated inside will have to query the database first?

CodePudding user response:

Can expand an attribute that is used to store the old value

CodePudding user response:

Yes, similar to (here only handwritten example, there may be grammar mistakes, it is good to understand)
 & lt; Asp: Text ID="txtABC Text='& lt; % # Bind (" field_a ") % & gt; 'the old value=Text=' & lt; % # Bind (" field_a ") % & gt; '.../> 
double bind, through the custom attributes bind the old value (formatted as text type), then you can read the attribute value, such as
 protected void GridView1_RowUpdating (object sender, GridViewUpdateEventArgs e) 
{
Var TXT=(TextBox) e.I tem. FindControl (" txtABC ");
String v=TXT. Attribute [] "old value";
.
}
can use custom attributes to save the business meaning of field information,

CodePudding user response:


& lt; Asp: TextBox ID="name" runat="server" Text='& lt; % # Bind (" name ") % & gt; '& gt;


Using a hidden value, save the old values, update more than txtbox values are in line,
  • Related