stamm528
stamm528

Reputation: 113

How to change checkbox after page load

I have a checkbox that needs to update when the user changes the selected item in a GridView. I can programmatically assign the database value to the checkbox on page load. That works fine. But I can't get the checkbox to refresh inside my GridView_SelectedIndexChanged function.

radioBtnDownPmtBrwd.Checked = Convert.ToBoolean(lstBorrowerInfo.rbDwnPmtBrwd);
radioBtnEndorser.Checked = Convert.ToBoolean(lstBorrowerInfo.rbEndorser);

The code above works great on Page_Load. How do I trigger the screen to refresh when I change the checked/unchecked status from the code behind?

Upvotes: 0

Views: 463

Answers (1)

Karl Anderson
Karl Anderson

Reputation: 34846

You need to rebind the GridView in the event handler code for the selected item changing. The GridView will only show what its DataSource says it has upon the most recent DataBind method call.

Putting this within an UpdatePanel will get rid of the blink refresh that occurs with standard ASP.NET WebForms postbacks, but UpdatePanels are not a panacea.

Upvotes: 1

Related Questions