Private Sub BindGrid(Optional ByVal SortField As String = "Eventdate") Dim strUID, strSQL As String strUID = DeCrypt(Session("UID")) strSQL = "select Registry_ID as [ID] ,RegistryName As [Registry Name], RegistryDesc As [Description], " & _ "EventDate as [Event Date] from registry where registrant_ID ='" & strUID & "' order by '" & SortField & "'" Dim DS As DataSet Dim MyConnection As New SqlConnection() Dim MyCommand As SqlDataAdapter MyCommand = New SqlDataAdapter(strSQL, SQLcn) DS = New DataSet("MyRegistryDS") MyCommand.Fill(DS, "registry") grdReg.DataSource = DS.Tables("registry").DefaultView 'Source.Sort = E.SortExpression 'grdReg.Columns(1).ItemStyle.Width = System.Web.UI.WebControls.Unit.Pixel(1) Page.DataBind() MyConnection.Close() strLastSortField = SortField End SubMy Datagrid source looks like this: (My apologis for the mangled code but it was unmanagably wide in the preview.
<asp:datagrid id="grdReg" runat="server" Width="719px" Height="117px" Font-Names="Arial" BorderColor="#BE9A64" BorderStyle="None" CellSpacing="4" BorderWidth="1px" BackColor="#DEBA84" CellPadding="3" HorizontalAlign="Center" AllowPaging="True" AllowSorting="True" GridLines="Horizontal" PageSize="5"><SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#738A9C"></SelectedItemStyle><ItemStyle Wrap="False" ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle><HeaderStyle Font-Size="Smaller" Font- Names="Arial" Font-Bold="True" Wrap="False" HorizontalAlign="Center" ForeColor="SaddleBrown" VerticalAlign="Middle" BackColor="#BE9A64"></HeaderStyle><FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></FooterStyle> <Columns><asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" CancelText="Cancel" EditText="Edit Registry"></asp:EditCommandColumn></Columns> <PagerStyle Font-Size="XX-Small" Font-Names="Arial Black" HorizontalAlign="Center" ForeColor="#8C4510" Position="TopAndBottom" Mode="NumericPages"></PagerStyle></asp:datagrid><STRONG></span></form>
"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams