I am initializing a GridView, text box and a button via code to a Webpart in CreateChildControls()
The above controls are declared as class variables but initialized only later.
Next, I've given the handler for button click. The handler function is supposed to work as a search - perform some operations on the content entered in the textbox, load the results in the Gridview, display the Gridview
When I type something in the text box and hit the button, the same controls load again and the content entered in the text box is lost. I've tried ViewState() and ViewState() but to no avail. The grid doesn't show because my logic skips attempting to bind it since a proper search string was not available.
My questions: 1) Where/how can I get the values postback from the textbox? 2) Will it make sense to populate the GridView in PreRender() or will Event Handling happen after PreRender()?
EDIT: Seems like the event handler is not getting called.
Dim btnClickHandler = New EventHandler(AddressOf SetSearchParameter)
AddHandler srchBtn.Click, btnClickHandler
is correct?
EDIT: I redid all code from 0. Its working now.