page load

kunal.kb

Member
Joined
Sep 8, 2005
Messages
21
Programming Experience
Beginner
hello all...
in my aspx.vb file the page load event is getting called twice....
on that form i have a datagrid....data in the datagrid is coming from database...
the page has a table,in that table the controls are added at run time(dynamic)....
can any one tell me why the page load is getting called twice....
thank you
 
Page Load

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myconnStr = CommonFunctions.ConnectionString()
myconnection = New SqlConnection(myconnStr)
Header1.PageLabel = "Edit User"
Header1.MenuLinkURL = "AppAdmin"
If Not IsPostBack Then
If DGridUser.Attributes("SortExpression") Is Nothing Then
DGridUser.Attributes("SortExpression") = "User_ID"
DGridUser.Attributes("SortDirection") = "ASC"
End If
CreateControls()
bindgrid()
btnDelete.Attributes.Add("onclick", "result=window.confirm('Are you sure you want to delete?');return result;")
'Put user code to initialize the page here
txtUserCode.Attributes.Add("onkeypress", "return blockSpecialChars(this, event);")
txtUserName.Attributes.Add("onkeypress", "return blockSpecialChars(this, event);")
Dim nav As String = Session("treeNav")
Header1.Navigate = nav
Header1.Navigate += "-> "
Header1.Navigate += Header1.PageLabel.ToString.Trim
'Session("treeNav") = header1.Navigate
End If
 
Page Load

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myconnStr = CommonFunctions.ConnectionString()
myconnection = New SqlConnection(myconnStr)
Header1.PageLabel = "Edit User"
Header1.MenuLinkURL = "AppAdmin"
If Not IsPostBack Then
If DGridUser.Attributes("SortExpression") Is Nothing Then
DGridUser.Attributes("SortExpression") = "User_ID"
DGridUser.Attributes("SortDirection") = "ASC"
End If
CreateControls()
bindgrid()
btnDelete.Attributes.Add("onclick", "result=window.confirm('Are you sure you want to delete?');return result;")
'Put user code to initialize the page here
txtUserCode.Attributes.Add("onkeypress", "return blockSpecialChars(this, event);")
txtUserName.Attributes.Add("onkeypress", "return blockSpecialChars(this, event);")
Dim nav As String = Session("treeNav")
Header1.Navigate = nav
Header1.Navigate += "-> "
Header1.Navigate += Header1.PageLabel.ToString.Trim
'Session("treeNav") = header1.Navigate
End If
----------------------------------------------------------------------
in this code
createcontrols is generating checkboxes dynamically....
and bindgrid is binding data to the datagrid
 
try this

VB.NET:
        If Page.IsPostBack = False Then
            If DGridUser.Attributes("SortExpression") Is Nothing Then
                DGridUser.Attributes("SortExpression") = "User_ID"
                DGridUser.Attributes("SortDirection") = "ASC"
            CreateControls()
             bindgrid()
            End If
if you could post CreateControls() and bindgrid() code it would help. by the way put your code in code tags.
 
Back
Top