J
Jim Mitchell
I have the following code for the Datagrid. If I set
AUTOGENERATECOLUMNS=FALSE. The PageIndexChanged routine does not fire and
the Datagrid disappears on the postback. Everything works great if
Autogeneratecolumns is set to true.
HELP! PLEASE!
Private Sub dgAccounts_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dgAccounts.PageIndexChanged
TextBox1.Text = "IT DID GET CALLED"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim mycn As SqlClient.SqlConnection
Dim sql_string As String
Dim daAccounts As SqlClient.SqlDataAdapter
Dim dsAccounts As New DataSet
Dim dcolumn As New System.Web.UI.WebControls.ButtonColumn
mycn = New
SqlClient.SqlConnection(System.Configuration.ConfigurationSettings.AppSettin
gs("ConnectString"))
sql_string = "Select ID, Company, Phone from tblCompanys where
(N_UserCompany<" & "16 AND Len(rtrim(Company)) > 0) order by Company asc"
daAccounts = New SqlClient.SqlDataAdapter(sql_string, mycn)
daAccounts.Fill(dsAccounts)
dgAccounts.DataSource = dsAccounts
dcolumn.ButtonType = ButtonColumnType.LinkButton
dcolumn.DataTextField = "Company"
dcolumn.HeaderText = "Header here"
dgAccounts.Columns.Add(dcolumn)
dgAccounts.DataBind()
mycn.Close()
End Sub
AUTOGENERATECOLUMNS=FALSE. The PageIndexChanged routine does not fire and
the Datagrid disappears on the postback. Everything works great if
Autogeneratecolumns is set to true.
HELP! PLEASE!
Private Sub dgAccounts_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dgAccounts.PageIndexChanged
TextBox1.Text = "IT DID GET CALLED"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim mycn As SqlClient.SqlConnection
Dim sql_string As String
Dim daAccounts As SqlClient.SqlDataAdapter
Dim dsAccounts As New DataSet
Dim dcolumn As New System.Web.UI.WebControls.ButtonColumn
mycn = New
SqlClient.SqlConnection(System.Configuration.ConfigurationSettings.AppSettin
gs("ConnectString"))
sql_string = "Select ID, Company, Phone from tblCompanys where
(N_UserCompany<" & "16 AND Len(rtrim(Company)) > 0) order by Company asc"
daAccounts = New SqlClient.SqlDataAdapter(sql_string, mycn)
daAccounts.Fill(dsAccounts)
dgAccounts.DataSource = dsAccounts
dcolumn.ButtonType = ButtonColumnType.LinkButton
dcolumn.DataTextField = "Company"
dcolumn.HeaderText = "Header here"
dgAccounts.Columns.Add(dcolumn)
dgAccounts.DataBind()
mycn.Close()
End Sub