Hi @gal mor ,
You can use View State
, which is the way to preserve Page and Controls values between round trips. It is a page-level state management technique.
https://learn.microsoft.com/en-us/previous-versions/dotnet/articles/ms972976(v=msdn.10)?redirectedfrom=MSDN
These are the main features of view state,
- Retains the value of the Control after post-back without using a session.
- Stores the value of Pages and Control Properties defined in the page.
- Creates a custom View State Provider that lets you store View State Information in a SQL Server Database or in another data store.
According to your previous post, are you trying to set EnableViewState
to false
? The documentation states:
https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.gridview?redirectedfrom=MSDN&view=netframework-4.8#data-operations
The GridView control is re-created on postback based on the information that is stored in
ViewState
. If the GridView control includes aTemplateField
or aCommandField
with theCausesValidation
property set totrue
, then theEnableViewState
property must also be set totrue
to ensure that concurrent data operations, such as updates and deletes, apply to the appropriate row.
Note that the if (!IsPostBack)
needs to be removed when using EnableViewState="false"
.
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.