Question regarding forcing a postback event

Discussion in 'ASP .Net Building Controls' started by Michael Horton, Jun 29, 2003.

  1. I've dynamically creating a datagrid and have the grid setup to allow
    sorting. The problem is that the event isn't getting called until after the
    table is created. How can I get it to to fire earler? I'm guessing I need to
    know how to find out what the e.sortexpression value is and call the
    procedure before calling the CreateGrid sub. I've attached the code
    CreateGrid sub below

    Public Sub CreateGrid()

    'declare a new datagrid and set properties

    Dim dgDrivers As New DataGrid()

    dgDrivers.BorderWidth = Unit.Pixel(0)

    dgDrivers.CellPadding = 5

    dgDrivers.GridLines = GridLines.None

    dgDrivers.BorderColor = System.Drawing.Color.Empty

    dgDrivers.ShowHeader = True

    dgDrivers.AutoGenerateColumns = False

    dgDrivers.SelectedItemStyle.BackColor = System.Drawing.Color.Empty

    dgDrivers.AllowSorting = True

    'add bound columns to the datagrid

    Dim datagridcol As New BoundColumn()

    datagridcol.HeaderText = "Car #"

    datagridcol.DataField = "car #"

    datagridcol.SortExpression = "Car #"

    dgDrivers.Columns.Add(datagridcol)

    datagridcol = New BoundColumn()

    datagridcol.HeaderText = "Name"

    datagridcol.DataField = "Name"

    datagridcol.SortExpression = "Name"

    dgDrivers.Columns.Add(datagridcol)

    datagridcol = New BoundColumn()

    datagridcol.HeaderText = "Status"

    datagridcol.DataField = "Status"

    'datagridcol.DataFormatString = "{0:d}"

    datagridcol.SortExpression = "Status"

    dgDrivers.Columns.Add(datagridcol)

    datagridcol = New BoundColumn()

    datagridcol.HeaderText = "Hometown"

    datagridcol.DataField = "Hometown"

    datagridcol.SortExpression = "HomeTown"

    dgDrivers.Columns.Add(datagridcol)

    'add event handlers

    AddHandler dgDrivers.SortCommand, AddressOf dgDriver_Sort

    dgDrivers.DataSource = DisplayDrivers()

    dgDrivers.DataBind()

    'add datagrid to the page

    Page.Controls(1).Controls.Add(dgDrivers)

    End Sub




    --
    Michael Horton
    http://www.cta-racing.com
    Michael Horton, Jun 29, 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. Earl Teigrob
    Replies:
    0
    Views:
    400
    Earl Teigrob
    Aug 11, 2003
  2. Earl Teigrob
    Replies:
    2
    Views:
    696
    Earl Teigrob
    Dec 23, 2003
  3. Ashish

    Forcing parent page postback

    Ashish, Apr 5, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    6,251
    Steven Cheng[MSFT]
    Apr 8, 2004
  4. =?Utf-8?B?VGFicmV6?=

    Forcing PostBack programmitically

    =?Utf-8?B?VGFicmV6?=, Jun 19, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,907
    =?Utf-8?B?VGFicmV6?=
    Jun 21, 2004
  5. Michael Horton

    Question regarding forcing a postback event

    Michael Horton, Jun 29, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    119
    Michael Horton
    Jun 29, 2003
Loading...

Share This Page