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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top