HELP - Problem with DG Postback when not using AutoFillColumns

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top