Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Columns on DataGrid without AutoGenerating Columns 1

Status
Not open for further replies.

jmeckley

Programmer
Jul 15, 2002
5,269
US
I would like my users to be able to sort the datagrid by column heading. However, the Columns do not allow me to sort if I do not auto generate the columns. what is the work around for this or am I missing something.

I am showing the header
I have allow sorting checked
Here is the asp
<TT>
<asp:datagrid id=&quot;dgWO&quot; runat=&quot;server&quot; GridLines=&quot;Vertical&quot; CellPadding=&quot;3&quot; BackColor=&quot;White&quot; BorderWidth=&quot;1px&quot; BorderStyle=&quot;None&quot; BorderColor=&quot;#999999&quot; AllowSorting=&quot;True&quot; OnSortCommand=&quot;dgWO_Sort&quot; AutoGenerateColumns=&quot;False&quot;>
<SelectedItemStyle Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; BackColor=&quot;#008A8C&quot;></SelectedItemStyle>
<AlternatingItemStyle BackColor=&quot;Gainsboro&quot;></AlternatingItemStyle>
<ItemStyle ForeColor=&quot;Black&quot; BackColor=&quot;#EEEEEE&quot;></ItemStyle>
<HeaderStyle Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; BackColor=&quot;#000084&quot;></HeaderStyle>
<FooterStyle ForeColor=&quot;Black&quot; BackColor=&quot;#CCCCCC&quot;></FooterStyle>
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField=&quot;WorkOrderID&quot; DataNavigateUrlFormatString=&quot;ViewRequest.aspx?ID={0}&quot; DataTextField=&quot;WorkOrderID&quot; HeaderText=&quot;Work Order&quot; NavigateUrl=&quot;ViewDubRequest.aspx&quot;>
<ItemStyle HorizontalAlign=&quot;Center&quot;></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField=&quot;Status&quot; HeaderText=&quot;Status&quot;></asp:BoundColumn>
<asp:BoundColumn DataField=&quot;DueDate&quot; HeaderText=&quot;Due Date&quot;></asp:BoundColumn>
<asp:BoundColumn DataField=&quot;Title&quot; HeaderText=&quot;Title&quot;></asp:BoundColumn>
<asp:BoundColumn DataField=&quot;TapeNumber&quot; HeaderText=&quot;Tape Number&quot;></asp:BoundColumn>
<asp:BoundColumn DataField=&quot;DisplayName&quot; HeaderText=&quot;Requested By&quot;></asp:BoundColumn>
<asp:ButtonColumn Text=&quot;Delete&quot; CommandName=&quot;Delete&quot;></asp:ButtonColumn>
</Columns>
<PagerStyle HorizontalAlign=&quot;Center&quot; ForeColor=&quot;Black&quot; BackColor=&quot;#999999&quot; Mode=&quot;NumericPages&quot;></PagerStyle>
</asp:datagrid>
</TT>

Jason Meckley
Database Analyst
WITF
 
You need to use the SortExpression=&quot;xxxx&quot; where xxxx is the name of the column to sort on.

Dee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top