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 Test Or Check Dead Pixels And Backlight Bleed On Your Monitor Using Dead Pixel Checker In Windows 11

How To Insert Or Add Emojis In Microsoft Teams Status Message