HELP - Problem with DG Postback when not using AutoFillColumns

Discussion in 'ASP .Net Datagrid Control' started by Jim Mitchell, Jul 16, 2003.

  1. Jim Mitchell

    Jim Mitchell Guest

    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
    Jim Mitchell, Jul 16, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Psych971
    Replies:
    5
    Views:
    4,588
    bruce barker
    Dec 17, 2004
  2. =?Utf-8?B?Q2hhZA==?=

    Postback not being set to True on first postback

    =?Utf-8?B?Q2hhZA==?=, Apr 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    478
    =?Utf-8?B?Q2hhZA==?=
    Apr 4, 2005
  3. gce
    Replies:
    2
    Views:
    1,689
  4. Jacky Chau
    Replies:
    2
    Views:
    2,019
    Ninjamyst
    Jun 8, 2005
  5. Fabio Mastria
    Replies:
    5
    Views:
    4,326
    TechMCAD13
    Jan 30, 2008
Loading...

Share This Page