Donate

ASP.NET Web Forms GridView RowUpdating Event Not Getting New Values From Controls

I have a code in rowupdating event which get's values from textbox controls during edit mode. However, when update command button is clicked, the values from the controls were cleared or null. So, I checked the page load event, and found out that I have a code which rebinds the grid when it is not post back since the update link button will trigger postback. Here is the page load code:
if(!string.IsNullOrEmpty(Request.QueryString["LoanNum"]))  
 {  
  ShowToControls(Convert.ToInt32(Request.QueryString["LoanNum"]));  
  BindGridDetails(Convert.ToInt32(Request.QueryString["LoanNum"]));  
 }  
So, the modified pageload code should add a IsPostback condition so that the binding of gridview will not be executed. Here's the modified script:
if(!string.IsNullOrEmpty(Request.QueryString["LoanNum"])  
  && !Page.IsPostBack)  
 {  
  ShowToControls(Convert.ToInt32(Request.QueryString["LoanNum"]));  
  BindGridDetails(Convert.ToInt32(Request.QueryString["LoanNum"]));  
 } 

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.