Sometimes ButtonControl is recognisedsometimes not
I have button control in aspx page which is in formView. On page load sometimes it recognises btn Control, sometimes not. Please help took 1 day not of any success here is the code
My aspx button control is like this <asp:button ID="btnAdd" runat="server" Text="Add" commandName="insert" CausesValidation="false" OnClick="btnInsert_Click"
/>
Page Load:
PPdataFlag = objSrchDlt.displaySrchFavList(ppID, userID, count)
If PPdataFlag = "No" Then
myBtn = CType(frmView.FindControl("btnAdd"), Button) 'it gives Nothing here
myBtn.Text = "Add" 'it complains here object reference required
Dim myLabel As Label
myLabel = CType(frmView.FindControl("lblList"), Label)
myLabel.Text = "No"
If records > 1 Then
Call GetSearchUsersPPID()
Call SetPreviousNextButtons(hdnQueryString.Value)
Else
'disable button if the records found in favList Table are one
Dim preBtn As Button
preBtn = CType(frmView.FindControl("btnPrev"), Button)
Dim nexBtn As Button
nexBtn = CType(frmView.FindControl("btnNext"), Button)
preBtn.Enabled = False
nexBtn.Enabled = False
End If
End If
|