Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Michael Horton #1
Question regarding forcing a postback event
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
[url]http://www.cta-racing.com[/url]
Michael Horton Guest
-
LoadViewState does not fire on a postback event
Hi there, I need some help please. I have created a composite control that have a collection of items associated with it. Now I want to save this... -
Possible to tell what generated a postback event?
I'm writing a webpage with a datagrid that has pagenation (is that a word? LOL) and has some buttons in a column that I put there dynamically in an... -
Using the DataGrid's ItemCreated event on PostBack
I have a DataGrid with a series of transactions and wish to highlight negative value items in red. This is simple on the initial DataBind, by using... -
how to fire a postback event
Hi, All I design a composite custom control, which has three dropdownlists in it. I find as long as one of the dropdownlist control's id is... -
Forcing Page Postback at END of event (while retaining viewstate)
I have a page that reads values from an XML file to display to the user. The page also has a control panel that allows administrators to update the...



Reply With Quote

