void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
ICollection h_aligns =
TypeDescriptor.GetConverter ( typeof ( HorizontalAlign ) ).GetStandardValues ( );
foreach ( HorizontalAlign h in h_aligns ) {
AlignSelect.Items.Add ( h.ToString ( ) );
}
AlignSelect.SelectedIndex = 2;
string query = "SELECT Lastname, Firstname, Address, City, Country FROM Employees";
myGridView.DataSource = fetchData ( query, "northwind" );
myGridView.DataBind ( );
}
myGridView.ItemStyle.HorizontalAlign = ( HorizontalAlign ) AlignSelect.SelectedIndex;
}
Sub Page_Load ( src As Object, e As EventArgs )
If Not IsPostBack Then
Dim h_aligns As ICollection = _
TypeDescriptor.GetConverter ( GetType ( HorizontalAlign ) ).GetStandardValues ( )
Dim h As HorizontalAlign
For Each h In h_aligns
AlignSelect.Items.Add ( h.ToString ( ) )
Next h
AlignSelect.SelectedIndex = 2
Dim query As String = "SELECT Lastname, Firstname, Address, City, Country FROM Employees"
myGridView.DataSource = fetchData ( query, "northwind" )
myGridView.DataBind ( )
End If
myGridView.ItemStyle.HorizontalAlign = CType ( AlignSelect.SelectedIndex, HorizontalAlign )
End Sub |